From 1bffd981321ad2394b97c7d096fc56afdb364a72 Mon Sep 17 00:00:00 2001 From: "Maksym H." Date: Sun, 1 Sep 2024 17:13:13 +0300 Subject: [PATCH] Localize `get_translator` call --- api.lua | 2 +- init.lua | 3 +++ onjoin.lua | 2 +- player_recipients.lua | 4 +++- ui/about.lua | 2 +- ui/compose.lua | 2 +- ui/contacts.lua | 2 +- ui/drafts.lua | 3 +-- ui/edit_contact.lua | 2 +- ui/edit_maillists.lua | 2 +- ui/inbox.lua | 2 +- ui/maillists.lua | 2 +- ui/message.lua | 2 +- ui/outbox.lua | 2 +- ui/select_contact.lua | 2 +- ui/settings.lua | 2 +- ui/trash.lua | 2 +- util/contact.lua | 2 +- util/normalize.lua | 3 ++- util/settings.lua | 2 +- util/time_ago.lua | 2 +- 21 files changed, 26 insertions(+), 21 deletions(-) diff --git a/api.lua b/api.lua index 8da15f3..4fde5c7 100644 --- a/api.lua +++ b/api.lua @@ -1,7 +1,7 @@ -- see: mail.md -- translation -local S = minetest.get_translator("mail") +local S = mail.S local f = string.format diff --git a/init.lua b/init.lua index cdc19ec..8de0bec 100644 --- a/init.lua +++ b/init.lua @@ -5,6 +5,9 @@ mail = { -- mod storage storage = minetest.get_mod_storage(), + -- translation + S = minetest.get_translator(minetest.get_current_modname()), + -- ui theme prepend theme = "", diff --git a/onjoin.lua b/onjoin.lua index d5f4648..ef602e5 100644 --- a/onjoin.lua +++ b/onjoin.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S minetest.register_on_joinplayer(function(player) minetest.after(2, function(name) diff --git a/player_recipients.lua b/player_recipients.lua index 7586b98..0812dfb 100644 --- a/player_recipients.lua +++ b/player_recipients.lua @@ -1,4 +1,6 @@ -local S = minetest.get_translator("mail") +-- translation +local S = mail.S + local has_canonical_name = minetest.get_modpath("canonical_name") mail.register_on_player_receive(function(name, msg) diff --git a/ui/about.lua b/ui/about.lua index 09b0d59..0be025d 100644 --- a/ui/about.lua +++ b/ui/about.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S local FORMNAME = "mail:about" diff --git a/ui/compose.lua b/ui/compose.lua index d78a10a..62d16a2 100644 --- a/ui/compose.lua +++ b/ui/compose.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S local FORMNAME = "mail:compose" diff --git a/ui/contacts.lua b/ui/contacts.lua index 2b1a7d5..3978251 100644 --- a/ui/contacts.lua +++ b/ui/contacts.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S local FORMNAME = "mail:contacts" diff --git a/ui/drafts.lua b/ui/drafts.lua index a7da0a0..003e3cc 100644 --- a/ui/drafts.lua +++ b/ui/drafts.lua @@ -1,6 +1,5 @@ -- translation -local S = minetest.get_translator("mail") - +local S = mail.S function mail.show_drafts(name) local trash_tab = "" diff --git a/ui/edit_contact.lua b/ui/edit_contact.lua index 1eeea16..c8e00e3 100644 --- a/ui/edit_contact.lua +++ b/ui/edit_contact.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S local FORMNAME = "mail:editcontact" diff --git a/ui/edit_maillists.lua b/ui/edit_maillists.lua index a35ac1d..ac36022 100644 --- a/ui/edit_maillists.lua +++ b/ui/edit_maillists.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S local FORMNAME = "mail:editmaillist" diff --git a/ui/inbox.lua b/ui/inbox.lua index 019bb0f..526fc6f 100644 --- a/ui/inbox.lua +++ b/ui/inbox.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S function mail.show_inbox(name, sortfieldindex, sortdirection, filter) sortfieldindex = tonumber(sortfieldindex or mail.selected_idxs.sortfield[name]) diff --git a/ui/maillists.lua b/ui/maillists.lua index f8b0522..9ba8a52 100644 --- a/ui/maillists.lua +++ b/ui/maillists.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S local FORMNAME = "mail:maillists" diff --git a/ui/message.lua b/ui/message.lua index a213ef3..7f3447e 100644 --- a/ui/message.lua +++ b/ui/message.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S local FORMNAME = "mail:message" diff --git a/ui/outbox.lua b/ui/outbox.lua index 4017e28..667bf1c 100644 --- a/ui/outbox.lua +++ b/ui/outbox.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S function mail.show_outbox(name, sortfieldindex, sortdirection, filter) sortfieldindex = tonumber(sortfieldindex or mail.selected_idxs.sortfield[name]) diff --git a/ui/select_contact.lua b/ui/select_contact.lua index 42a5071..33438d1 100644 --- a/ui/select_contact.lua +++ b/ui/select_contact.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S local FORMNAME = "mail:selectcontact" diff --git a/ui/settings.lua b/ui/settings.lua index b1e4851..9323fe5 100644 --- a/ui/settings.lua +++ b/ui/settings.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S local FORMNAME = "mail:settings" diff --git a/ui/trash.lua b/ui/trash.lua index e90f0ea..eee516f 100644 --- a/ui/trash.lua +++ b/ui/trash.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S local trash_formspec = "size[8.5,11;]" .. mail.theme .. [[ tabheader[0.3,1;boxtab;]] .. diff --git a/util/contact.lua b/util/contact.lua index 763558f..b890f43 100644 --- a/util/contact.lua +++ b/util/contact.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S function mail.compile_contact_list(name, selected, playernames) -- TODO: refactor this - not just compiles *a* list, but *the* list for the contacts screen (too inflexible) diff --git a/util/normalize.lua b/util/normalize.lua index 0be01ea..4585bd5 100644 --- a/util/normalize.lua +++ b/util/normalize.lua @@ -1,4 +1,5 @@ -local S = minetest.get_translator("mail") +-- translation +local S = mail.S local function recursive_expand_recipient_names(sender, list, is_toplevel, recipients, undeliverable) for _, name in ipairs(list) do diff --git a/util/settings.lua b/util/settings.lua index c82db03..4c21e71 100644 --- a/util/settings.lua +++ b/util/settings.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S mail.settings = { chat_notifications = { diff --git a/util/time_ago.lua b/util/time_ago.lua index 39d912a..0fc2c3e 100644 --- a/util/time_ago.lua +++ b/util/time_ago.lua @@ -1,5 +1,5 @@ -- translation -local S = minetest.get_translator("mail") +local S = mail.S function mail.time_ago(t) local elapsed = os.time() - t