Files
ox_lib/resource/locale/client.lua
Linden fb2225e373 chore: add copyright notices to each file
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.
2025-03-18 18:46:09 +11:00

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)