diff --git a/docs_md/changelog.md b/docs_md/changelog.md index d26860a..832edd1 100644 --- a/docs_md/changelog.md +++ b/docs_md/changelog.md @@ -138,3 +138,4 @@ Desc - Input component: rename field _selected_ to _is_selected_ (according to the docs) - Add EmmyLua annotations. See how to use it FAQ +- Lang text now can be initialized without default locale id diff --git a/druid/extended/lang_text.lua b/druid/extended/lang_text.lua index b62aa6e..64479d1 100644 --- a/druid/extended/lang_text.lua +++ b/druid/extended/lang_text.lua @@ -21,7 +21,7 @@ local LangText = component.create("lang_text", { component.ON_LANGUAGE_CHANGE }) --- Component init function -- @tparam LangText self -- @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 function LangText.init(self, node, locale_id, no_adjust) self.druid = self:get_druid() @@ -30,7 +30,9 @@ function LangText.init(self, node, locale_id, no_adjust) self.on_change = Event() - self:translate(locale_id) + if locale_id then + self:translate(locale_id) + end return self end @@ -59,7 +61,7 @@ end function LangText.translate(self, locale_id, ...) self.last_locale_args = {...} 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