-- ============================================================================ -- M-Minigames :: locale helper -- Loads locales/.json once and exposes L(key, ...) to both realms. -- Kept separate from ox_lib's locale system so this resource stays usable -- even in a setup where ox_lib locales are configured for another language. -- ============================================================================ local strings = {} local fallback = {} local function load(lang) local raw = LoadResourceFile(GetCurrentResourceName(), ('locales/%s.json'):format(lang)) if not raw then return {} end local ok, decoded = pcall(json.decode, raw) return (ok and type(decoded) == 'table') and decoded or {} end fallback = load('en') strings = load(Config.Language or 'sl') ---Locale lookup with string.format arguments. Falls back to English, then to ---the key itself, so a missing string is visible rather than blank. function L(key, ...) local text = strings[key] or fallback[key] or key if select('#', ...) > 0 then local ok, formatted = pcall(string.format, text, ...) if ok then return formatted end end return text end