mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
#147 Remove ... from lang_text to fixed arguments, add lang_text:format additional functions
This commit is contained in:
parent
d0c91c9cb5
commit
43adb5f52d
15
druid/extended/lang_text.lua
Normal file → Executable file
15
druid/extended/lang_text.lua
Normal file → Executable file
@ -61,11 +61,20 @@ end
|
||||
--- Translate the text by locale_id
|
||||
-- @tparam LangText self
|
||||
-- @tparam string locale_id Locale id
|
||||
function LangText.translate(self, locale_id, ...)
|
||||
self.last_locale_args = {...}
|
||||
-- @tparam string ... Locale arguments to pass in text function
|
||||
function LangText.translate(self, locale_id, a, b, c, d, e, f, g)
|
||||
self.last_locale_args = { a, b, c, d, e, f, g }
|
||||
self.last_locale = locale_id or self.last_locale
|
||||
self.text:set_to(settings.get_text(self.last_locale, ...) or "")
|
||||
self.text:set_to(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "")
|
||||
end
|
||||
|
||||
|
||||
--- Format string with new text params on localized text
|
||||
-- @tparam LangText self
|
||||
-- @tparam string ... Locale arguments to pass in text function
|
||||
function LangText.format(self, a, b, c, d, e, f, g)
|
||||
self.last_locale_args = { a, b, c, d, e, f, g }
|
||||
self.text:set_to(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "")
|
||||
end
|
||||
|
||||
return LangText
|
||||
|
2
druid/system/settings.lua
Normal file → Executable file
2
druid/system/settings.lua
Normal file → Executable file
@ -9,7 +9,7 @@ local M = {}
|
||||
M.default_style = nil
|
||||
|
||||
|
||||
function M.get_text(name, ...)
|
||||
function M.get_text(name, a, b, c, d, e, f, g)
|
||||
return "[Druid]: locales not inited"
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user