mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
refactor(locale): simplify
BREAKING CHANGE (kind of) Remove user-selection for locales. Adds mostly unnecessary complexity, and most people don't want to bother with it anyway. Locale is always based on the convar "ox:locale" instead.
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
do
|
||||
local locales = {}
|
||||
local system = os.getenv('OS')
|
||||
local command = system and system:match('Windows') and 'dir "' or 'ls "'
|
||||
local path = GetResourcePath(lib.name)
|
||||
local types = path:gsub('//', '/') .. '/locales'
|
||||
local suffix = command == 'dir "' and '/" /b' or '/"'
|
||||
local dir = io.popen(command .. types .. suffix)
|
||||
|
||||
if dir then
|
||||
for line in dir:lines() do
|
||||
local file = line:gsub('([%a%-]+).json', '%1')
|
||||
|
||||
if file then
|
||||
locales[#locales+1] = file
|
||||
end
|
||||
end
|
||||
dir:close()
|
||||
end
|
||||
|
||||
GlobalState.locales = locales
|
||||
end
|
||||
|
||||
RegisterCommand('serverlocale', function(_, args, _)
|
||||
if args?[1] then
|
||||
SetResourceKvp('locale', args[1])
|
||||
TriggerEvent('ox_lib:setLocale', args[1])
|
||||
end
|
||||
end, true)
|
||||
|
||||
function lib.getServerLocale()
|
||||
return GetResourceKvpString('locale') or 'en'
|
||||
end
|
||||
Reference in New Issue
Block a user