This commit is contained in:
Insality
2024-11-27 23:34:50 +02:00
parent 06f682e8e4
commit 434dce55ce
16 changed files with 252 additions and 157 deletions

View File

@@ -72,13 +72,21 @@ end
---@return druid.lang_text Current instance
function M:set_to(text)
self.last_locale = false
self.text:set_to(text)
self.text:set_text(text)
self.on_change:trigger()
return self
end
--- Setup raw text to lang_text component
---@param text string Text for text node
---@return druid.lang_text Current instance
function M:set_text(text)
return self:set_to(text)
end
--- Translate the text by locale_id
---@param locale_id string Locale id
---@param a string|nil Optional param to string.format
@@ -92,7 +100,7 @@ end
function M:translate(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, a, b, c, d, e, f, g) or "")
self.text:set_text(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "")
return self
end
@@ -109,7 +117,7 @@ end
---@return druid.lang_text Current instance
function M:format(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 "")
self.text:set_text(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "")
return self
end