mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 17:28:53 +00:00
32 lines
646 B
Lua
32 lines
646 B
Lua
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
|
|
return 'Locale [' .. Config.Locale .. '] does not exist'
|
|
end
|
|
|
|
end
|
|
|
|
function _U(str, ...) -- Translate string first char uppercase
|
|
return tostring(_(str, ...):gsub("^%l", string.upper))
|
|
end
|
|
|
|
function LoadLocale(ns, lang, data)
|
|
|
|
Locales[lang] = Locales[lang] or {}
|
|
|
|
for k,v in pairs(data) do
|
|
Locales[lang][ns .. ':' .. k] =v
|
|
end
|
|
|
|
end
|