mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 10:27:47 +02:00
Add locale_id in Lang Text component optional
This commit is contained in:
parent
b254448e54
commit
fe3ac2e985
@ -138,3 +138,4 @@ Desc
|
|||||||
|
|
||||||
- Input component: rename field _selected_ to _is_selected_ (according to the docs)
|
- Input component: rename field _selected_ to _is_selected_ (according to the docs)
|
||||||
- Add EmmyLua annotations. See how to use it FAQ
|
- Add EmmyLua annotations. See how to use it FAQ
|
||||||
|
- Lang text now can be initialized without default locale id
|
||||||
|
@ -21,7 +21,7 @@ local LangText = component.create("lang_text", { component.ON_LANGUAGE_CHANGE })
|
|||||||
--- Component init function
|
--- Component init function
|
||||||
-- @tparam LangText self
|
-- @tparam LangText self
|
||||||
-- @tparam node node The text node
|
-- @tparam node node The text node
|
||||||
-- @tparam string locale_id Default locale id
|
-- @tparam string locale_id Default locale id, optional
|
||||||
-- @tparam bool no_adjust If true, will not correct text size
|
-- @tparam bool no_adjust If true, will not correct text size
|
||||||
function LangText.init(self, node, locale_id, no_adjust)
|
function LangText.init(self, node, locale_id, no_adjust)
|
||||||
self.druid = self:get_druid()
|
self.druid = self:get_druid()
|
||||||
@ -30,7 +30,9 @@ function LangText.init(self, node, locale_id, no_adjust)
|
|||||||
|
|
||||||
self.on_change = Event()
|
self.on_change = Event()
|
||||||
|
|
||||||
self:translate(locale_id)
|
if locale_id then
|
||||||
|
self:translate(locale_id)
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -59,7 +61,7 @@ end
|
|||||||
function LangText.translate(self, locale_id, ...)
|
function LangText.translate(self, locale_id, ...)
|
||||||
self.last_locale_args = {...}
|
self.last_locale_args = {...}
|
||||||
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, ...))
|
self.text:set_to(settings.get_text(self.last_locale, ...) or "")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user