mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
refactor(client/locale): send GlobalState.locales to ui
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
local default = { 'en', 'fr', 'de', 'it', 'es', 'pt-BR', 'pl', 'ru', 'ko', 'zh-TW', 'ja', 'es-MX', 'zh-CN' }
|
local default = { 'en', 'fr', 'de', 'it', 'es', 'pt-BR', 'pl', 'ru', 'ko', 'zh-TW', 'ja', 'es-MX', 'zh-CN' }
|
||||||
local uiLoaded = false
|
|
||||||
local userLocale = GetResourceKvpString('locale') or default[GetCurrentLanguage() + 1]
|
local userLocale = GetResourceKvpString('locale') or default[GetCurrentLanguage() + 1]
|
||||||
|
|
||||||
local function loadLocale(locale, cb)
|
local function loadLocale(locale, cb)
|
||||||
@@ -22,24 +21,17 @@ RegisterNUICallback('closeSettings', function(_, cb)
|
|||||||
SetNuiFocus(false, false)
|
SetNuiFocus(false, false)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
RegisterNUICallback('init', function(_, cb)
|
||||||
|
cb(1)
|
||||||
|
|
||||||
Citizen.CreateThread(function()
|
SendNUIMessage({
|
||||||
while not uiLoaded do Wait(0) end
|
|
||||||
|
|
||||||
SendNUIMessage({ -- Loads the `default` array into select options
|
|
||||||
action = 'loadLocales',
|
action = 'loadLocales',
|
||||||
data = default
|
data = GlobalState.locales
|
||||||
})
|
})
|
||||||
|
|
||||||
loadLocale(userLocale)
|
loadLocale(userLocale)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
RegisterNUICallback('init', function(_, cb)
|
|
||||||
cb(1)
|
|
||||||
uiLoaded = true
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterCommand('ox_lib', function()
|
RegisterCommand('ox_lib', function()
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'openSettings',
|
action = 'openSettings',
|
||||||
|
|||||||
Reference in New Issue
Block a user