mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-28 17:01:14 +00:00
refactor translate function
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user