diff --git a/[core]/es_extended/locale.lua b/[core]/es_extended/locale.lua index db77eba7..7d940e4f 100644 --- a/[core]/es_extended/locale.lua +++ b/[core]/es_extended/locale.lua @@ -3,21 +3,23 @@ Locales = {} function Translate(str, ...) -- Translate string if not str then error(("Resource ^5%s^1 You did not specify a parameter for the Translate function or the value is nil!"):format(GetInvokingResource() or GetCurrentResourceName())) - return "Given translate function parameter is nil!" end - 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"] and Locales["en"][str] then - return string.format(Locales["en"][str], ...) - else - return "Translation [" .. Config.Locale .. "][" .. str .. "] does not exist" + + local translations = Locales[Config.Locale] + if not translations then + -- Fall back to English translation if the current locale is not found + if Locales.en and Locales.en[str] then + return Locales.en[str]:format(...) 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" + + return ("Locale [%s] does not exist"):format(Config.Locale) end + + if translations[str] then + return translations[str]:format(...) + end + + return ("Translation [%s][%s] does not exist"):format(Config.Locale, str) end function TranslateCap(str, ...) -- Translate string first char uppercase