mirror of
https://github.com/jimathy/jim-payments.git
synced 2026-08-16 22:06:02 +01:00
Update locale function
This commit is contained in:
40
config.lua
40
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
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user