mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 15:06:02 +01:00
Some people accidentally, mistakenly, and without any malicious intent forget to attribute code from this resource to its source. This change will hopefully assist people, so that they do not make that mistake again.
39 lines
936 B
Lua
39 lines
936 B
Lua
--[[
|
|
https://github.com/overextended/ox_lib
|
|
|
|
This file is licensed under LGPL-3.0 or higher <https://www.gnu.org/licenses/lgpl-3.0.en.html>
|
|
|
|
Copyright (c) 2025 Linden <https://github.com/thelindat/fivem>
|
|
]]
|
|
|
|
local settings = require 'resource.settings'
|
|
|
|
local function loadLocaleFile(key)
|
|
local file = LoadResourceFile(cache.resource, ('locales/%s.json'):format(key))
|
|
or LoadResourceFile(cache.resource, 'locales/en.json')
|
|
|
|
return file and json.decode(file) or {}
|
|
end
|
|
|
|
function lib.getLocaleKey() return settings.locale end
|
|
|
|
---@param key string
|
|
function lib.setLocale(key)
|
|
TriggerEvent('ox_lib:setLocale', key)
|
|
SendNUIMessage({
|
|
action = 'setLocale',
|
|
data = loadLocaleFile(key)
|
|
})
|
|
end
|
|
|
|
RegisterNUICallback('init', function(_, cb)
|
|
cb(1)
|
|
|
|
SendNUIMessage({
|
|
action = 'setLocale',
|
|
data = loadLocaleFile(settings.locale)
|
|
})
|
|
end)
|
|
|
|
lib.locale(settings.locale)
|