Deleted all files in the examples directory to clean up unused or test scripts. Updated fxmanifest.lua to enable ox_lib initialization. Improved error handling and entity tracking in utility functions, added prop removal, and made minor localization and code style adjustments throughout the codebase. Significant reword of inventory module, notification module, and framework module. Added support for wasabi_uikit, added support for keep-progressbars,
50 lines
1.5 KiB
Lua
50 lines
1.5 KiB
Lua
local ConvarLang = GetConvar("lang", "none")
|
|
local OXLang = GetConvar("ox:locale", "none")
|
|
local QBXLang = GetConvar("qb_locale", "none")
|
|
local txLang = GetConvar("txAdmin-locale", "none")
|
|
local esxLang = GetConvar("esx:locale", "none")
|
|
|
|
BridgeSharedConfig = Require("settings/sharedConfig.lua")
|
|
|
|
Lang = ConvarLang ~= "none" and
|
|
ConvarLang or BridgeSharedConfig.Lang ~= "auto" and BridgeSharedConfig.Lang or
|
|
OXLang ~= "none" and OXLang or
|
|
QBXLang ~= "none" and QBXLang or
|
|
txLang ~= "none" and txLang or
|
|
esxLang ~= "none" and esxLang or
|
|
"en"
|
|
|
|
Language = {}
|
|
|
|
function Language.Locale(str, ...)
|
|
local resource = GetInvokingResource() or GetCurrentResourceName()
|
|
assert(resource, "Resource name not found")
|
|
|
|
local locales = LoadResourceFile(resource, "locales/" .. Lang .. ".json")
|
|
locales = locales and json.decode(locales) or {}
|
|
|
|
-- Handle nested tables via dot notation
|
|
local current = locales
|
|
for part in str:gmatch("([^%.]+)") do
|
|
if type(current) ~= "table" then
|
|
warn(("Invalid nested locale path: %s for resource: %s"):format(str, resource))
|
|
return str
|
|
end
|
|
current = current[part]
|
|
if not current then
|
|
warn(("Locale not found for key: %s in language: %s for resource: %s"):format(str, Lang, resource))
|
|
return str
|
|
end
|
|
end
|
|
|
|
-- Handle variable replacement
|
|
local args = {...}
|
|
|
|
if type(current) == "string" and #args > 0 then
|
|
current = string.format(current, ...)
|
|
end
|
|
|
|
return current
|
|
end
|
|
|
|
return Language |