#147 Remove ... from lang_text to fixed arguments, add lang_text:format additional functions

This commit is contained in:
Insality 2021-11-20 11:14:04 +02:00
parent d0c91c9cb5
commit 43adb5f52d
2 changed files with 13 additions and 4 deletions

15
druid/extended/lang_text.lua Normal file → Executable file
View File

@ -61,11 +61,20 @@ end
--- Translate the text by locale_id --- Translate the text by locale_id
-- @tparam LangText self -- @tparam LangText self
-- @tparam string locale_id Locale id -- @tparam string locale_id Locale id
function LangText.translate(self, locale_id, ...) -- @tparam string ... Locale arguments to pass in text function
self.last_locale_args = {...} 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.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 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 return LangText

2
druid/system/settings.lua Normal file → Executable file
View File

@ -9,7 +9,7 @@ local M = {}
M.default_style = nil 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" return "[Druid]: locales not inited"
end end