mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
fix(locale): setLocale
This commit is contained in:
@@ -23,8 +23,7 @@ function lib.getLocales()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function lib.loadLocale()
|
function lib.loadLocale()
|
||||||
local locale = GetConvar('ox:locale', 'en')
|
local JSON = LoadResourceFile(cache.resource, ('locales/%s.json'):format(GetConvar('ox:locale', 'en'))) or LoadResourceFile(cache.resource, 'locales/en.json')
|
||||||
local JSON = LoadResourceFile(cache.resource, ('locales/%s.json'):format(locale)) or LoadResourceFile(cache.resource, ('locales/en.json'):format(locale))
|
|
||||||
dict = JSON and json.decode(JSON) or {}
|
dict = JSON and json.decode(JSON) or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"language": "繁體中文",
|
"language": "繁體中文",
|
||||||
"ui": {
|
"ui": {
|
||||||
"settings": {
|
"settings": {
|
||||||
"title": "設置",
|
"title": "設置",
|
||||||
"language": "語言"
|
"language": "語言"
|
||||||
},
|
},
|
||||||
"cancel": "取消",
|
"cancel": "取消",
|
||||||
"close": "關閉",
|
"close": "關閉",
|
||||||
"confirm": "確認"
|
"confirm": "確認"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
---@todo remove module and nui event
|
|
||||||
RegisterNUICallback('init', function(_, cb)
|
RegisterNUICallback('init', function(_, cb)
|
||||||
cb(1)
|
cb(1)
|
||||||
|
|
||||||
@@ -6,4 +5,11 @@ RegisterNUICallback('init', function(_, cb)
|
|||||||
action = 'loadLocales',
|
action = 'loadLocales',
|
||||||
data = {}
|
data = {}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local JSON = LoadResourceFile(cache.resource, ('locales/%s.json'):format(GetConvar('ox:locale', 'en'))) or LoadResourceFile(cache.resource, 'locales/en.json')
|
||||||
|
|
||||||
|
SendNUIMessage({
|
||||||
|
action = 'setLocale',
|
||||||
|
data = JSON and json.decode(JSON) or {}
|
||||||
|
})
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user