From 3df183653d3f2d24afce5598d11395078df701f9 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Sat, 20 Apr 2024 07:07:11 +1000 Subject: [PATCH] feat(settings): ox:userLocales convar --- locales/en.json | 1 + resource/settings.lua | 40 ++++++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/locales/en.json b/locales/en.json index 3790401..35f5273 100644 --- a/locales/en.json +++ b/locales/en.json @@ -1,5 +1,6 @@ { "language": "English", + "settings": "Settings", "ui": { "cancel": "Cancel", "close": "Close", diff --git a/resource/settings.lua b/resource/settings.lua index f92c87f..38a11b3 100644 --- a/resource/settings.lua +++ b/resource/settings.lua @@ -10,7 +10,9 @@ local settings = { 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) if settings[key] == value then return false end @@ -36,16 +38,11 @@ local function set(key, value) end RegisterCommand('ox_lib', function() - local input = lib.inputDialog('Settings', { + local inputSettings = { { - 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', + type = 'checkbox', + label = locale('ui.settings.notification_audio'), + checked = settings.notification_audio, }, { type = 'select', @@ -64,12 +61,23 @@ RegisterCommand('ox_lib', function() required = true, icon = 'message', }, - { - type = 'checkbox', - label = locale('ui.settings.notification_audio'), - checked = settings.notification_audio, - } - }) --[[@as table?]] + } + + if userLocales then + table.insert(inputSettings, + { + 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