refactor translate function

This commit is contained in:
Csoki
2022-09-15 00:24:55 +02:00
parent f665fc2c7f
commit dffaa5caae
+6 -10
View File
@@ -1,19 +1,15 @@
Locales = {}
function _(str, ...) -- Translate string
if Locales[Config.Locale] ~= nil then
if Locales[Config.Locale][str] ~= nil then
return string.format(Locales[Config.Locale][str], ...)
else
return 'Translation [' .. Config.Locale .. '][' .. str .. '] does not exist'
end
else
if not Locales[Config.Locale] then
return 'Locale [' .. Config.Locale .. '] does not exist'
end
if Locales[Config.Locale][str] then
return string.format(Locales[Config.Locale][str], ...)
end
return 'Translation [' .. Config.Locale .. '][' .. str .. '] does not exist'
end
function _U(str, ...) -- Translate string first char uppercase