Update locale function

This commit is contained in:
Jim Shield
2025-10-29 03:04:02 +00:00
parent 35c95f500d
commit d05d8626c4

View File

@@ -12,13 +12,13 @@ Config = {
Notify = "gta", -- "qb", "ox", "gta", "esx" Notify = "gta", -- "qb", "ox", "gta", "esx"
ProgressBar = "gta", -- "qb", "ox", "gta", "esx" ProgressBar = "gta", -- "qb", "ox", "gta", "esx"
DontUseTarget = false, -- uses drawtext targets instead of alt targets DontUseTarget = false, -- uses drawtext targets instead of alt targets
}, },
Crafting = { Crafting = {
craftCam = true,
MultiCraft = true, MultiCraft = true,
MultiCraftAmounts = { [1], [5], [10] },
showItemBox = true, showItemBox = true,
}, },
@@ -159,13 +159,35 @@ Config = {
PlayerGang, PlayerJob, onDuty = {}, {}, nil PlayerGang, PlayerJob, onDuty = {}, {}, nil
-- Test function for locales -- Function for locales
-- Don't touch unless you know what you're doing
-- This needs to be here because it loads before everything else
function locale(section, string) function locale(section, string)
if not Config.Lan or Config.Lan == "" then return print("Error, no langauge set") end if not Config.Lan or Config.Lan == "" then
local localTable = Loc[Config.Lan] print("^1Error^7: ^3Config^7.^3Lan ^1not set^7, ^2falling back to Config.Lan = 'en'")
if not localTable then return "Locale Table Not Found" end Config = Config or {}
if not localTable[section] then return "["..section.."] Invalid" end Config.Lan = "en"
if not localTable[section][string] then return "["..string.."] Invalid" end end
return localTable[section][string]
local localTable = Loc[Config.Lan]
-- If Loc[..] doesn't exist, warn user
if not localTable then
print("Locale Table '"..Config.Lan.."' Not Found")
return "Locale Table '"..Config.Lan.."' Not Found"
end
-- If Loc[..].section doesn't exist, warn user
if not localTable[section] then
print("^1Error^7: Locale Section: ['"..section.."'] Invalid")
return "Locale Section: ['"..section.."'] Invalid"
end
-- If Loc[..].section.string doesn't exist, warn user
if not localTable[section][string] then
print("^1Error^7: Locale String: ['"..section.."']['"..string.."'] Invalid")
return "Locale String: ['"..string.."'] Invalid"
end
-- If no issues, return the string
return localTable[section][string]
end end