mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
fix(package/locale): sync behaviour with Lua
This commit is contained in:
@@ -52,7 +52,7 @@ end
|
|||||||
local table = lib.table
|
local table = lib.table
|
||||||
|
|
||||||
---Loads the ox_lib locale module. Prefer using fxmanifest instead (see [docs](https://overextended.dev/ox_lib#usage)).
|
---Loads the ox_lib locale module. Prefer using fxmanifest instead (see [docs](https://overextended.dev/ox_lib#usage)).
|
||||||
---@param key string
|
---@param key? string
|
||||||
function lib.locale(key)
|
function lib.locale(key)
|
||||||
local lang = key or lib.getLocaleKey()
|
local lang = key or lib.getLocaleKey()
|
||||||
local locales = loadLocale('en')
|
local locales = loadLocale('en')
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ export const locale = (str: string, ...args: any[]) => {
|
|||||||
|
|
||||||
return lstr;
|
return lstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getLocales = () => dict;
|
export const getLocales = () => dict;
|
||||||
@@ -55,7 +57,7 @@ function loadLocale(key: string): typeof dict {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const initLocale = (key?: string) => {
|
export const initLocale = (key?: string) => {
|
||||||
const lang = key || GetConvar('ox:locale', 'en');
|
const lang = key || exports.ox_lib.getLocaleKey();
|
||||||
let locales = loadLocale('en');
|
let locales = loadLocale('en');
|
||||||
|
|
||||||
if (lang !== 'en') Object.assign(locales, loadLocale(lang));
|
if (lang !== 'en') Object.assign(locales, loadLocale(lang));
|
||||||
|
|||||||
Reference in New Issue
Block a user