From d05d8626c45360bcc0f6b55cc810bba6e45f29ed Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Wed, 29 Oct 2025 03:04:02 +0000 Subject: [PATCH] Update locale function --- config.lua | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/config.lua b/config.lua index 7f74f3f..57f1970 100644 --- a/config.lua +++ b/config.lua @@ -12,13 +12,13 @@ Config = { Notify = "gta", -- "qb", "ox", "gta", "esx" ProgressBar = "gta", -- "qb", "ox", "gta", "esx" + + DontUseTarget = false, -- uses drawtext targets instead of alt targets }, Crafting = { - craftCam = true, MultiCraft = true, - MultiCraftAmounts = { [1], [5], [10] }, showItemBox = true, }, @@ -159,13 +159,35 @@ Config = { 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) - if not Config.Lan or Config.Lan == "" then return print("Error, no langauge set") end - local localTable = Loc[Config.Lan] - if not localTable then return "Locale Table Not Found" end - if not localTable[section] then return "["..section.."] Invalid" end - if not localTable[section][string] then return "["..string.."] Invalid" end - return localTable[section][string] + if not Config.Lan or Config.Lan == "" then + print("^1Error^7: ^3Config^7.^3Lan ^1not set^7, ^2falling back to Config.Lan = 'en'") + Config = Config or {} + Config.Lan = "en" + end -end + 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 \ No newline at end of file