feat(settings): ox:userLocales convar

This commit is contained in:
Linden
2024-04-20 07:07:11 +10:00
parent 3959f76aae
commit 3df183653d
2 changed files with 25 additions and 16 deletions

View File

@@ -1,5 +1,6 @@
{ {
"language": "English", "language": "English",
"settings": "Settings",
"ui": { "ui": {
"cancel": "Cancel", "cancel": "Cancel",
"close": "Close", "close": "Close",

View File

@@ -10,7 +10,9 @@ local settings = {
notification_audio = GetResourceKvpInt('notification_audio') == 1 notification_audio = GetResourceKvpInt('notification_audio') == 1
} }
settings.locale = GetResourceKvpString('locale') or settings.default_locale local userLocales = GetConvarInt('ox:userLocales', 1) == 1
settings.locale = userLocales and GetResourceKvpString('locale') or settings.default_locale
local function set(key, value) local function set(key, value)
if settings[key] == value then return false end if settings[key] == value then return false end
@@ -36,16 +38,11 @@ local function set(key, value)
end end
RegisterCommand('ox_lib', function() RegisterCommand('ox_lib', function()
local input = lib.inputDialog('Settings', { local inputSettings = {
{ {
type = 'select', type = 'checkbox',
label = locale('ui.settings.locale'), label = locale('ui.settings.notification_audio'),
searchable = true, checked = settings.notification_audio,
description = locale('ui.settings.locale_description', settings.locale),
options = GlobalState['ox_lib:locales'],
default = settings.locale,
required = true,
icon = 'book',
}, },
{ {
type = 'select', type = 'select',
@@ -64,12 +61,23 @@ RegisterCommand('ox_lib', function()
required = true, required = true,
icon = 'message', icon = 'message',
}, },
{ }
type = 'checkbox',
label = locale('ui.settings.notification_audio'), if userLocales then
checked = settings.notification_audio, table.insert(inputSettings,
} {
}) --[[@as table?]] type = 'select',
label = locale('ui.settings.locale'),
searchable = true,
description = locale('ui.settings.locale_description', settings.locale),
options = GlobalState['ox_lib:locales'],
default = settings.locale,
required = true,
icon = 'book',
})
end
local input = lib.inputDialog(locale('settings'), inputSettings) --[[@as table?]]
if not input then return end if not input then return end