mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
refactor(locale): merge locales with english definitions
Also sync some recent changes in the TS module.
This commit is contained in:
@@ -46,23 +46,19 @@ export function getLocale(resource: string, key: string) {
|
||||
return locale;
|
||||
}
|
||||
|
||||
export const initLocale = () => {
|
||||
const lang = GetConvar('ox:locale', 'en');
|
||||
let locales: typeof dict = JSON.parse(LoadResourceFile(cache.resource, `locales/${lang}.json`));
|
||||
function loadLocale(key: string): typeof dict {
|
||||
const data = LoadResourceFile(cache.resource, `locales/${key}.json`);
|
||||
|
||||
if (!locales) {
|
||||
console.warn(`could not load 'locales/${lang}.json'`);
|
||||
if (!data) console.warn(`could not load 'locales/${key}.json'`);
|
||||
|
||||
if (lang !== 'en') {
|
||||
locales = JSON.parse(LoadResourceFile(cache.resource, 'locales/en.json'));
|
||||
return JSON.parse(data) || {};
|
||||
}
|
||||
|
||||
if (!locales) {
|
||||
console.warn(`could not load 'locales/en.json'`);
|
||||
}
|
||||
}
|
||||
export const initLocale = (key?: string) => {
|
||||
const lang = key || GetConvar('ox:locale', 'en');
|
||||
let locales = loadLocale('en');
|
||||
|
||||
if (!locales) return;
|
||||
}
|
||||
if (lang !== 'en') Object.assign(locales, loadLocale(lang));
|
||||
|
||||
const flattened = flattenDict(locales, {});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user