#76 add params for lang text string.format

This commit is contained in:
Insality
2020-07-18 22:16:24 +03:00
parent a561892fb6
commit f182439f2a
4 changed files with 17 additions and 8 deletions

View File

@@ -7,8 +7,8 @@ local function setup_druid()
sound.play("kenney:/sound#" .. name)
end)
druid.set_text_function(function(lang_id)
return lang.get_locale(lang_id)
druid.set_text_function(function(lang_id, ...)
return lang.get_locale(lang_id, ...)
end)
druid.on_language_change()

View File

@@ -44,8 +44,14 @@ local ru = {
local data = en
function M.get_locale(lang_id)
return data[lang_id] or lang_id
function M.get_locale(lang_id, ...)
local localized_text = data[lang_id] or lang_id
if #{...} > 0 then
localized_text = string.format(localized_text, ...)
end
return localized_text
end