feat(es_extended/locale.lua): Rename + default to English

renames:
_ -> Translate
_U -> TranslateCap
yes, it keeps compatibility

default:
defaults to English if the translation is not there, so u can still use the script
This commit is contained in:
Mycroft
2022-10-09 00:51:26 +01:00
parent 6187a289a4
commit a9457a7f55
+12 -8
View File
@@ -1,21 +1,25 @@
Locales = {}
function _(str, ...) -- Translate string
function Translate(str, ...) -- Translate string
if Locales[Config.Locale] ~= nil then
if Locales[Config.Locale][str] ~= nil then
if Locales[Config.Locale] then
if Locales[Config.Locale][str] then
return string.format(Locales[Config.Locale][str], ...)
elseif Config.Locale ~= 'en' and Locales['en'][str] then
return string.format(Locales['en'][str], ...)
else
return 'Translation [' .. Config.Locale .. '][' .. str .. '] does not exist'
end
elseif Config.Locale ~= 'en' and Locales['en'] and Locales['en'][str] then
return string.format(Locales['en'][str], ...)
else
return 'Locale [' .. Config.Locale .. '] does not exist'
end
end
function _U(str, ...) -- Translate string first char uppercase
return tostring(_(str, ...):gsub("^%l", string.upper))
function TranslateCap(str, ...) -- Translate string first char uppercase
return _(str, ...):gsub("^%l", string.upper)
end
_ = Translate
_U = TranslateCap