Fixed support for incomplete translations (fallback to default language for missing strings)

This commit is contained in:
Côme Chilliet 2017-08-10 16:31:00 +02:00
parent 044aa1d8eb
commit 47f01b3f6f

View file

@ -50,8 +50,8 @@ end
-- Find a string by its translate key in the right language
function t(key)
if conf.lang and i18n[conf.lang] then
return i18n[conf.lang][key] or ""
if conf.lang and i18n[conf.lang] and i18n[conf.lang][key] then
return i18n[conf.lang][key]
else
return i18n[conf["default_language"]][key] or ""
end
@ -556,13 +556,8 @@ function get_data_for(view)
end
-- Pass all the translated strings to the view (to use with t_<key>)
if conf.lang and i18n[conf.lang] then
translate_table = i18n[conf.lang]
else
translate_table = i18n[conf["default_language"]]
end
for k, v in pairs(translate_table) do
data["t_"..k] = v
for k, v in pairs(i18n[conf["default_language"]]) do
data["t_"..k] = i18n[conf.lang][k] or v
end
-- Pass flash notification content