Update locale function

This commit is contained in:
Jim Shield
2025-10-29 03:01:29 +00:00
parent 49d595e9c0
commit a26c7d018d

View File

@@ -4,12 +4,11 @@ Config = {
Debug = false, Debug = false,
EventDebug = false, EventDebug = false,
Menu = "qb", Menu = "qb", -- "qb", "ox", "lation", "gta"
Notify = "gta", Notify = "gta", -- "qb", "ox", "esx", "lation", "okok", "gta"
enableCam = true, -- Enables customs cameras when crafting etc.
}, },
Crafting = {
craftCam = true,
}
} }
SkateboardItemModels = { SkateboardItemModels = {
@@ -40,14 +39,35 @@ lastItem = nil
surfboard = false surfboard = false
-- 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 string then if not Config.Lan or Config.Lan == "" then
print(section, "string is nil") print("^1Error^7: ^3Config^7.^3Lan ^1not set^7, ^2falling back to Config.Lan = 'en'")
end Config = Config or {}
if not Config.Lan or Config.Lan == "" then return print("Error, no langauge set") end Config.Lan = "en"
end
local localTable = Loc[Config.Lan] local localTable = Loc[Config.Lan]
if not localTable then return "Locale Table Not Found" end -- If Loc[..] doesn't exist, warn user
if not localTable[section] then return "["..section.."] Invalid" end if not localTable then
if not localTable[section][string] then return "["..string.."] Invalid" end 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] return localTable[section][string]
end end