mirror of
https://github.com/Insality/druid
synced 2025-06-27 18:37:45 +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
|
--- 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
2
druid/system/settings.lua
Normal file → Executable 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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user