mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
refactor(imports): assign modules directly to lib namespace
Mostly a change for improved intellisense with sumneko lua. Includes some type fixes and deprecation notices.
This commit is contained in:
@@ -14,15 +14,16 @@ function locale(str, ...)
|
||||
return ("Translation for '%s' does not exist"):format(str)
|
||||
end
|
||||
|
||||
local function loadLocale(locale)
|
||||
function lib.loadLocale(locale)
|
||||
if not locale then
|
||||
locale = lib.service == 'server' and lib.getServerLocale() or GetExternalKvpString('ox_lib', 'locale') or 'en'
|
||||
end
|
||||
|
||||
local resourceName = GetCurrentResourceName()
|
||||
local JSON = LoadResourceFile(resourceName, ('locales/%s.json'):format(locale)) or LoadResourceFile(resourceName, ('locales/en.json'):format(locale))
|
||||
dict = JSON and json.decode(JSON) or {}
|
||||
end
|
||||
|
||||
AddEventHandler('ox_lib:setLocale', loadLocale)
|
||||
AddEventHandler('ox_lib:setLocale', lib.loadLocale)
|
||||
|
||||
return function()
|
||||
local lang = lib.service == 'server' and lib.getServerLocale() or GetExternalKvpString('ox_lib', 'locale') or 'en'
|
||||
loadLocale(lang)
|
||||
end
|
||||
return lib.loadLocale
|
||||
Reference in New Issue
Block a user