fix(shared/locale): only construct phrases for strings

This commit is contained in:
Linden
2023-01-16 18:18:51 +11:00
parent fe58a4893f
commit 6fbdd49702

View File

@@ -26,6 +26,7 @@ function lib.loadLocale()
local locales = json.decode(LoadResourceFile(cache.resource, ('locales/%s.json'):format(GetConvar('ox:locale', 'en'))) or LoadResourceFile(cache.resource, 'locales/en.json') or '[]') local locales = json.decode(LoadResourceFile(cache.resource, ('locales/%s.json'):format(GetConvar('ox:locale', 'en'))) or LoadResourceFile(cache.resource, 'locales/en.json') or '[]')
for k, v in pairs(locales) do for k, v in pairs(locales) do
if type(v) == 'string' then
for var in v:gmatch('${[%w%s%p]-}') do for var in v:gmatch('${[%w%s%p]-}') do
local locale = locales[var:sub(3, -2)] local locale = locales[var:sub(3, -2)]
@@ -33,6 +34,7 @@ function lib.loadLocale()
v = v:gsub(var, locale:gsub('%%', '%%%%')) v = v:gsub(var, locale:gsub('%%', '%%%%'))
end end
end end
end
dict[k] = v dict[k] = v
end end