diff --git a/[esx]/es_extended/locale.lua b/[esx]/es_extended/locale.lua index 68de6651..ed42aa76 100644 --- a/[esx]/es_extended/locale.lua +++ b/[esx]/es_extended/locale.lua @@ -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 \ No newline at end of file