mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-11-18 18:18:34 +00:00
feat(locale): locale hotloading
This commit is contained in:
1 parent
09ca963f26
commit
1e3b2cb567
4 files changed
+49
-10
No files matched your search
@@ -0,0 +1,14 @@
|
||||
local locales, localesN = lib.getFilesInDirectory('locales', '%.json')
|
||||
|
||||
for i = 1, localesN do
|
||||
local key = locales[i]
|
||||
local value = key:gsub('%.json', '')
|
||||
local label = (json.decode(LoadResourceFile(lib.name, ('locales/%s'):format(key)) or '') or '').language or value
|
||||
locales[i] = { label = label, value = value }
|
||||
end
|
||||
|
||||
table.sort(locales, function(a, b)
|
||||
return a.label < b.label
|
||||
end)
|
||||
|
||||
GlobalState['ox_lib:locales'] = locales
|
||||
Reference in new issue
Block a user