This commit is contained in:
parent
76e8e9db1a
commit
f24b6453d8
|
|
@ -41,5 +41,6 @@ export declare const LOCALE_CHANGE_HANDLER_NAME = "$_localeChange";
|
|||
export declare const CURRENT_LOCALE_DATA = "$_translations";
|
||||
export declare type I18nOptions = {
|
||||
translations?: Record<string, any>;
|
||||
defaultLocale?: string;
|
||||
};
|
||||
export declare function getI18next(options?: I18nOptions): I18nWechatMpRuntimeBase;
|
||||
|
|
|
|||
|
|
@ -96,19 +96,13 @@ exports.CURRENT_LOCALE_KEY = '$_locale';
|
|||
exports.LOCALE_CHANGE_HANDLER_NAME = '$_localeChange';
|
||||
exports.CURRENT_LOCALE_DATA = '$_translations';
|
||||
function getI18next(options) {
|
||||
var systemInfo = wx.getSystemInfoSync();
|
||||
var language = systemInfo.language; // 系统语言
|
||||
var translations = (options || { translations: {} }).translations;
|
||||
var defaultLocale = 'zh_CN';
|
||||
if (language) {
|
||||
defaultLocale = language;
|
||||
}
|
||||
var _a = options || {}, translations = _a.translations, defaultLocale = _a.defaultLocale;
|
||||
//初始化i18n
|
||||
var i18n = initI18nWechatMp({
|
||||
locales: {
|
||||
translations: translations,
|
||||
translations: translations || {},
|
||||
},
|
||||
defaultLocale: defaultLocale,
|
||||
defaultLocale: defaultLocale || "zh_CN" /* Locale.default */,
|
||||
});
|
||||
return i18n;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,22 +136,17 @@ export const CURRENT_LOCALE_DATA = '$_translations';
|
|||
|
||||
export type I18nOptions = {
|
||||
translations?: Record<string, any>;
|
||||
defaultLocale?: string;
|
||||
};
|
||||
|
||||
export function getI18next(options?: I18nOptions) {
|
||||
const systemInfo = wx.getSystemInfoSync();
|
||||
const { language } = systemInfo; // 系统语言
|
||||
const { translations } = options || { translations: {} };
|
||||
let defaultLocale = 'zh_CN';
|
||||
if (language) {
|
||||
defaultLocale = language;
|
||||
}
|
||||
const { translations, defaultLocale } = options || {};
|
||||
//初始化i18n
|
||||
const i18n = initI18nWechatMp({
|
||||
locales: {
|
||||
translations: translations!,
|
||||
translations: translations || {},
|
||||
},
|
||||
defaultLocale,
|
||||
defaultLocale: defaultLocale || Locale.default,
|
||||
});
|
||||
return i18n;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue