fix(locale): always assign a table to dict

Prevent indexing nil when no locales exist for a resource.
This commit is contained in:
Linden
2022-06-19 17:34:32 +10:00
parent 7e171d2a20
commit 6c83adfda8

View File

@@ -17,10 +17,7 @@ end
local function loadLocale(locale) local function loadLocale(locale)
local resourceName = GetCurrentResourceName() local resourceName = GetCurrentResourceName()
local JSON = LoadResourceFile(resourceName, ('locales/%s.json'):format(locale)) or LoadResourceFile(resourceName, ('locales/en.json'):format(locale)) local JSON = LoadResourceFile(resourceName, ('locales/%s.json'):format(locale)) or LoadResourceFile(resourceName, ('locales/en.json'):format(locale))
dict = JSON and json.decode(JSON) or {}
if JSON then
dict = json.decode(JSON)
end
end end
AddEventHandler('ox_lib:setLocale', loadLocale) AddEventHandler('ox_lib:setLocale', loadLocale)