mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
feat(settings): ox:userLocales convar
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"language": "English",
|
"language": "English",
|
||||||
|
"settings": "Settings",
|
||||||
"ui": {
|
"ui": {
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"close": "Close",
|
"close": "Close",
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user