mirror of
https://github.com/jimathy/jim-boarding.git
synced 2026-03-31 06:33:43 -04:00
Update locale function
This commit is contained in:
44
config.lua
44
config.lua
@@ -4,12 +4,11 @@ Config = {
|
||||
Debug = false,
|
||||
EventDebug = false,
|
||||
|
||||
Menu = "qb",
|
||||
Notify = "gta",
|
||||
Menu = "qb", -- "qb", "ox", "lation", "gta"
|
||||
Notify = "gta", -- "qb", "ox", "esx", "lation", "okok", "gta"
|
||||
|
||||
enableCam = true, -- Enables customs cameras when crafting etc.
|
||||
},
|
||||
Crafting = {
|
||||
craftCam = true,
|
||||
}
|
||||
}
|
||||
|
||||
SkateboardItemModels = {
|
||||
@@ -40,14 +39,35 @@ lastItem = nil
|
||||
|
||||
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)
|
||||
if not string then
|
||||
print(section, "string is nil")
|
||||
end
|
||||
if not Config.Lan or Config.Lan == "" then return print("Error, no langauge set") end
|
||||
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 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
|
||||
-- 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