- remove locales module

This commit is contained in:
Mustachedom committed 2026-08-18 00:02:04 -07:00
1 parent d6cffd01bc
commit 07530a8662
25 files changed
+84 -724

No files matched your search

@@ -8,7 +8,7 @@ Dispatch.SendAlert = function(data)
if data.vehicle then
table.insert(metadata, {
type = 'vehicle',
model = data.vehicle or locale('unknown_vehicle_model'),
model = data.vehicle or lib.locale('unknown_vehicle_model'),
plate = data.plate or nil,
color = data.colorHex or nil
})
@@ -13,7 +13,7 @@ Dispatch.SendAlert = function(data)
if data.vehicle then
table.insert(metadata, {
type = 'vehicle',
model = data.vehicle or locale('unknown_vehicle_model'),
model = data.vehicle or lib.locale('unknown_vehicle_model'),
plate = data.plate or nil,
color = data.colorHex or nil
})
-50
View File
@@ -1,50 +0,0 @@
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
+1 -5
View File
@@ -5,10 +5,6 @@ Notify.GetResourceName = function()
return "default"
end
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
local placeHolderText = locale("Notifications.PlaceholderTitle")
---DEPRICATED: PLEASE SWITCH TO Notify.SendNotification
---12/13/25
---@param src number
@@ -31,7 +27,7 @@ end
Notify.SendNotification = function(src, title, message, _type, time, props)
time = time or 3000
if not title then
title = placeHolderText
title = lib.locale("Notifications.PlaceholderTitle")
end
TriggerClientEvent('community_bridge:Client:Notify', src, title, message, _type, time, props)
end
+1 -5
View File
@@ -9,10 +9,6 @@ Notify.GetResourceName = function()
return resourceName
end
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
local placeHolderText = locale("Notifications.PlaceholderTitle")
Notify.SendNotify = function(message, _type, time)
time = time or 3000
return exports['brutal_notify']:SendAlert('Notification', message, time, _type or "success", false)
@@ -27,7 +23,7 @@ end
---@return nil
Notify.SendNotification = function(title, message, _type, time, props)
time = time or 3000
if not title then title = placeHolderText end
if not title then title = lib.locale("Notifications.PlaceholderTitle") end
return exports['brutal_notify']:SendAlert(title, message, time, _type or "success", false)
end
+1 -6
View File
@@ -8,11 +8,6 @@ Notify.GetResourceName = function()
return resourceName
end
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
local placeHolderText = locale("Notifications.PlaceholderTitle")
Notify.SendNotify = function(message, _type, time)
time = time or 3000
if _type == "error" or _type == "info" then
@@ -36,7 +31,7 @@ end
---@return nil
Notify.SendNotification = function(title, message, _type, time, props)
time = time or 3000
if not title then title = placeHolderText end
if not title then title = lib.locale("Notifications.PlaceholderTitle") end
if _type == "error" or _type == "info" then
_type = tostring(1)
elseif _type == "success" then
+1 -4
View File
@@ -9,9 +9,6 @@ Notify.GetResourceName = function()
return resourceName
end
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
local placeHolderText = locale("Notifications.PlaceholderTitle")
Notify.SendNotify = function(message, _type, time)
@@ -28,7 +25,7 @@ end
---@return nil
Notify.SendNotification = function(title, message, _type, time, props)
time = time or 3000
if not title then title = placeHolderText end
if not title then title = lib.locale("Notifications.PlaceholderTitle") end
return exports.lation_ui:notify({ title = title, message = message, type = _type or "success", duration = time, position = 'top-right' })
end
+1 -4
View File
@@ -8,9 +8,6 @@ Notify.GetResourceName = function()
return resourceName
end
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
local placeHolderText = locale("Notifications.PlaceholderTitle")
---DEPRICATED: PLEASE SWITCH TO Notify.SendNotification
---@param message string
@@ -31,7 +28,7 @@ end
---@return nil
Notify.SendNotification = function(title, message, _type, time, props)
time = time or 3000
if not title then title = placeHolderText end
if not title then title = lib.locale("Notifications.PlaceholderTitle") end
return exports.msk_core:Notify(title, message, _type or "success", time)
end
+1 -5
View File
@@ -8,10 +8,6 @@ Notify.GetResourceName = function()
return resourceName
end
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
local placeHolderText = locale("Notifications.PlaceholderTitle")
Notify.SendNotify = function(message, _type, time)
time = time or 3000
_type = _type or "inform"
@@ -28,7 +24,7 @@ end
---@return nil
Notify.SendNotification = function(title, message, _type, time, props)
time = time or 3000
if not title then title = placeHolderText end
if not title then title = lib.locale("Notifications.PlaceholderTitle") end
_type = _type or "inform"
return exports['mythic_notify']:SendAlert(_type, message, time)
end
+1 -5
View File
@@ -8,10 +8,6 @@ Notify.GetResourceName = function()
return resourceName
end
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
local placeHolderText = locale("Notifications.PlaceholderTitle")
Notify.SendNotify = function(message, _type, time)
time = time or 3000
return exports['okokNotify']:Alert('Notification', message, time, _type or "Success", false)
@@ -27,7 +23,7 @@ end
---@return nil
Notify.SendNotification = function(title, message, _type, time, props)
time = time or 3000
if not title then title = placeHolderText end
if not title then title = lib.locale("Notifications.PlaceholderTitle") end
return exports['okokNotify']:Alert(title, message, time, _type or "Success", false)
end
+1 -6
View File
@@ -8,11 +8,6 @@ Notify.GetResourceName = function()
return resourceName
end
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
local placeHolderText = locale("Notifications.PlaceholderTitle")
Notify.SendNotify = function(message, _type, time)
time = time or 3000
return exports.ox_lib:notify({ description = message, type = _type, duration = time, position = 'top-right' })
@@ -27,7 +22,7 @@ end
---@return nil
Notify.SendNotification = function(title, message, _type, time, props)
time = time or 3000
if not title then title = placeHolderText end
if not title then title = lib.locale("Notifications.PlaceholderTitle") end
return exports.ox_lib:notify({ title = title, description = message, type = _type or "success", duration = time, position = 'top-right' })
end
+1 -5
View File
@@ -8,10 +8,6 @@ Notify.GetResourceName = function()
return resourceName
end
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
local placeHolderText = locale("Notifications.PlaceholderTitle")
Notify.SendNotify = function(message, _type, time)
time = time or 3000
return exports['pNotify']:SendNotification({ text = message, type = _type, timeout = time, layout = 'centerRight' })
@@ -27,7 +23,7 @@ end
---@return nil
Notify.SendNotification = function(title, message, _type, time, props)
time = time or 3000
if not title then title = placeHolderText end
if not title then title = lib.locale("Notifications.PlaceholderTitle") end
return exports['pNotify']:SendNotification({ title = title, text = message, type = _type or "success", timeout = time, layout = 'centerRight' })
end
+1 -5
View File
@@ -8,10 +8,6 @@ Notify.GetResourceName = function()
return resourceName
end
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
local placeHolderText = locale("Notifications.PlaceholderTitle")
Notify.SendNotify = function(message, _type, time)
time = time or 3000
return exports.r_notify:notify({title = 'Notification', content = message, type = _type, icon = "fas fa-check", duration = time, position = 'top-right', sound = false})
@@ -26,7 +22,7 @@ end
---@return nil
Notify.SendNotification = function(title, message, _type, time, props)
time = time or 3000
if not title then title = placeHolderText end
if not title then title = lib.locale("Notifications.PlaceholderTitle") end
return exports.r_notify:notify({title = title, content = message, type = _type or "success", icon = "fas fa-check", duration = time, position = 'top-right', sound = false})
end
+1 -5
View File
@@ -9,10 +9,6 @@ Notify.GetResourceName = function()
return resourceName
end
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
local placeHolderText = locale("Notifications.PlaceholderTitle")
Notify.SendNotify = function(message, _type, time)
time = time or 3000
@@ -28,7 +24,7 @@ end
---@return nil
Notify.SendNotification = function(title, message, _type, time, props)
time = time or 3000
if not title or title == "" then title = placeHolderText end
if not title or title == "" then title = lib.locale("Notifications.PlaceholderTitle") end
props = props or {}
+1 -5
View File
@@ -8,10 +8,6 @@ Notify.GetResourceName = function()
return resourceName
end
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
local placeHolderText = locale("Notifications.PlaceholderTitle")
Notify.SendNotify = function(message, _type, time)
time = time or 3000
_type = _type or "info"
@@ -27,7 +23,7 @@ end
---@return nil
Notify.SendNotification = function(title, message, _type, time, props)
time = time or 3000
if not title then title = placeHolderText end
if not title then title = lib.locale("Notifications.PlaceholderTitle") end
_type = _type or "info"
return exports['t-notify']:Alert({ title = title, style = _type, message = message, duration = time, })
end
+1 -5
View File
@@ -8,10 +8,6 @@ Notify.GetResourceName = function()
return resourceName
end
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
local placeHolderText = locale("Notifications.PlaceholderTitle")
Notify.SendNotify = function(message, _type, time)
time = time or 3000
_type = _type or "info"
@@ -27,7 +23,7 @@ end
---@return nil
Notify.SendNotification = function(title, message, _type, time, props)
time = time or 3000
if not title then title = placeHolderText end
if not title then title = lib.locale("Notifications.PlaceholderTitle") end
_type = _type or "info"
return exports.wasabi_notify:notify(_type, message, time, _type)
end
+2 -6
View File
@@ -8,10 +8,6 @@ Notify.GetResourceName = function()
return resourceName
end
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
local placeHolderText = locale("Notifications.PlaceholderTitle")
local function getIconByType(_type)
local icon = "info"
if _type == "success" then
@@ -27,7 +23,7 @@ end
Notify.SendNotify = function(message, _type, time)
time = time or 3000
local icon = getIconByType(_type)
local serial = exports['ZSX_UIV2']:Notification(placeHolderText, message, icon, time)
local serial = exports['ZSX_UIV2']:Notification(lib.locale("Notifications.PlaceholderTitle"), message, icon, time)
return serial
end
@@ -40,7 +36,7 @@ end
---@return nil
Notify.SendNotification = function(title, message, _type, time, props)
time = time or 3000
if not title then title = placeHolderText end
if not title then title = lib.locale("Notifications.PlaceholderTitle") end
local icon = getIconByType(_type)
exports['ZSX_UIV2']:Notification(title, message, icon, time)
end
+10 -10
View File
@@ -24,23 +24,23 @@ Shops.FinalizeCheckOut = function(shopName, item, itemLabel, price, amount)
local generatedID = lib.string.random('Aa1A', 8) -- Generate a random ID if not provided
local buildMenu = {
{
title = locale('Shops.PayByCash', tostring(mathStuff)),
description = locale('Shops.AreYouSure', itemLabel),
icon = locale('Shops.CashIcon'),
title = lib.locale('Shops.PayByCash', tostring(mathStuff)),
description = lib.locale('Shops.AreYouSure', itemLabel),
icon = lib.locale('Shops.CashIcon'),
onSelect = function(_, __, ___)
TriggerServerEvent('community_bridge:Server:completeCheckout', shopName, item, amount, "money")
end
},
{
title = locale('Shops.PayByCard', tostring(mathStuff)),
description = locale('Shops.AreYouSure', itemLabel),
icon = locale('Shops.CardIcon'),
title = lib.locale('Shops.PayByCard', tostring(mathStuff)),
description = lib.locale('Shops.AreYouSure', itemLabel),
icon = lib.locale('Shops.CardIcon'),
onSelect = function(_, __, ___)
TriggerServerEvent('community_bridge:Server:completeCheckout', shopName, item, amount, "bank")
end
}
}
Menu.Open({ id = generatedID, title = locale("Shops.Input"), options = buildMenu }, false)
Menu.Open({ id = generatedID, title = lib.locale("Shops.Input"), options = buildMenu }, false)
end
---This is an internal functions that is used to open the amount select menu. Please do not use this function directly.
@@ -57,7 +57,7 @@ Shops.AmountSelect = function(shopName, item, itemLabel, price)
table.insert(numberOptions, {label = tostring(i), value = i})
end
local _input = Input.Open(shopName, {
{type = 'select', label = locale("Shops.PurchaseAmount"), options = numberOptions},
{type = 'select', label = lib.locale("Shops.PurchaseAmount"), options = numberOptions},
})
if _input and _input[1] then
@@ -78,8 +78,8 @@ Shops.OpenShop = function(shopName, shopData)
local getItemName = Inventory.GetItemInfo(v.name).label
table.insert(buildMenu, {
title = getItemName,
description = locale('Shops.CurrencySymbol', tostring(v.price)),
icon = locale('Shops.ShopIcon'),
description = lib.locale('Shops.CurrencySymbol', tostring(v.price)),
icon = lib.locale('Shops.ShopIcon'),
onSelect = function(selected, secondary, args)
Shops.AmountSelect(shopName, v.name, getItemName, v.price)
end
+5 -8
View File
@@ -3,9 +3,6 @@ Shops = Shops or {}
local registeredShops = {}
local Language = Language or Require("modules/locales/shared.lua")
local locale = Language.Locale
---This can open a shop for the client
---@param src number
---@param shopName string
@@ -51,23 +48,23 @@ Shops.CompleteCheckout = function(src, shopName, item, amount, account)
end
end
if not itemData or not itemData.price then return print("community_bridge Player ID "..src.." attempted to purchase invalid item from shop: "..shopName) end
if itemData.count and itemData.count <= 0 then return Notify.SendNotify(src, locale('Shops.NotEnoughStock'), "error", 5000) end
if itemData.count and itemData.count <= 0 then return Notify.SendNotify(src, lib.locale('Shops.NotEnoughStock'), "error", 5000) end
local totalCost = tonumber(itemData.price) * amount
local balance = Framework.GetAccountBalance(src, account)
if not balance then return end
if balance <= 0 then return Notify.SendNotify(src, locale('Shops.NotEnoughMoney'), "error", 5000) end
if balance < totalCost then return Notify.SendNotify(src, locale('Shops.NotEnoughMoney'), "error", 5000) end
if balance <= 0 then return Notify.SendNotify(src, lib.locale('Shops.NotEnoughMoney'), "error", 5000) end
if balance < totalCost then return Notify.SendNotify(src, lib.locale('Shops.NotEnoughMoney'), "error", 5000) end
if not Framework.RemoveAccountBalance(src, account, totalCost) then return end
local success = Inventory.AddItem(src, itemData.name, amount)
if not success then
Framework.AddAccountBalance(src, account, totalCost)
return Notify.SendNotify(src, locale('Shops.PurchaseFailed'), "error", 5000)
return Notify.SendNotify(src, lib.locale('Shops.PurchaseFailed'), "error", 5000)
end
local itemLabel = Inventory.GetItemInfo(itemData.name).label or itemData.name
Notify.SendNotify(src, locale('Shops.PurchasedItem', amount, itemLabel), "success", 5000)
Notify.SendNotify(src, lib.locale('Shops.PurchasedItem', amount, itemLabel), "success", 5000)
end
---This is an internal event to complete a checkout, complete with multiple validations. Please do not use this event directly.
+6 -6
View File
@@ -83,12 +83,12 @@ function Target.AddLocalEntity(entities, _options)
end
for _, entity in pairs(entities) do
local id = lib.string.random('Aa1A', 8) -- Generate a random ID if not provided
local title = Language.Locale("target.title")
local title = lib.locale("target.title")
local menuData = { id = id, title = title, options = {} }
for k, v in pairs(fixedOptions) do
table.insert(menuData.options, {
title = title .. " " .. k,
description = Language.Locale("target.description"),
description = lib.locale("target.description"),
onSelect = function(selected, secondary, args)
if v.onSelect then
v.onSelect(selected, secondary, args)
@@ -99,7 +99,7 @@ function Target.AddLocalEntity(entities, _options)
Point.Register(id, entity, 5, nil, function()
local coords = GetEntityCoords(entity)
local sleep = 3000
local test = Language.Locale("target.interact")
local test = lib.locale("target.interact")
CreateThread(function()
while DoesEntityExist(entity) do
Wait(sleep)
@@ -131,12 +131,12 @@ end
function Target.AddBoxZone(name, coords, size, heading, options)
local fixedOptions = Target.FixOptions(options)
local id = lib.string.random('Aa1A', 8) -- Generate a random ID if not provided
local title = Bridge.Language.Locale("target.title")
local title = lib.locale("target.title")
local menuData = { id = id, title = title, options = {} }
for k, v in pairs(fixedOptions) do
table.insert(menuData.options, {
title = title .. " " .. k,
description = Bridge.Language.Locale("target.description"),
description = lib.locale("target.description"),
onSelect = function(selected, secondary, args)
if v.onSelect then
v.onSelect(selected, secondary, args)
@@ -153,7 +153,7 @@ function Target.AddBoxZone(name, coords, size, heading, options)
local distance = #(coords - GetEntityCoords(PlayerPedId()))
if distance < 10 then
sleep = 0
Utility.Draw3DHelpText(coords, Bridge.Language.Locale("target.interact"), 0.35)
Utility.Draw3DHelpText(coords, lib.locale("target.interact"), 0.35)
if IsControlJustPressed(0, 38) then
Menu.Open(menuData, false)
end