mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 09:48:52 +00:00
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:
@@ -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
|
||||
Reference in New Issue
Block a user