本文整理汇总了TypeScript中i18next.changeLanguage函数的典型用法代码示例。如果您正苦于以下问题:TypeScript changeLanguage函数的具体用法?TypeScript changeLanguage怎么用?TypeScript changeLanguage使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了changeLanguage函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: changeLanguage
vm.changeLanguage = () => {
localStorage.dimLanguage = vm.settings.language;
changeLanguage(vm.settings.language, () => {
$rootScope.$applyAsync(() => {
$rootScope.$broadcast('i18nextLanguageChange');
});
});
};
示例2: readyResolve
$rootScope.$evalAsync(() => {
const languageChanged = savedSettings.language !== i18next.language;
store.dispatch(loaded(savedSettings));
const settings = store.getState().settings;
localStorage.setItem('dimLanguage', settings.language);
if (languageChanged) {
i18next.changeLanguage(settings.language);
}
readyResolve();
// Start saving settings changes
unsubscribe = saveSettingsOnUpdate();
});
示例3:
const changeLng = (lng: string) => {
i18next.changeLanguage(lng);
};
示例4: de
const v: string = i18next.t('my.key');
const a: boolean = i18next.exists('my.key');
// fix language to german
const de = i18next.getFixedT('de');
const z: string = de('myKey');
// or fix the namespace to anotherNamespace
const anotherNamespace = i18next.getFixedT(null, 'anotherNamespace');
const x: string = anotherNamespace('anotherNamespaceKey'); // no need to prefix ns i18n.t('anotherNamespace:anotherNamespaceKey');
i18next.changeLanguage('en', (err: any, t: i18next.TranslationFunction) => {
if (err) {
console.log('something went wrong loading', err);
return;
}
t('key'); // -> same as i18next.t
});
i18next.loadNamespaces('myNamespace', (err: any, t: i18next.TranslationFunction) => { /* resources have been loaded */ });
i18next.loadNamespaces(['myNamespace1', 'myNamespace2'], (err: any, t: i18next.TranslationFunction) => { /* resources have been loaded */ });
i18next.loadLanguages('de', (err: any, t: i18next.TranslationFunction) => { /* resources have been loaded */ });
i18next.loadLanguages(['de', 'fr'], (err: any, t: i18next.TranslationFunction) => { /* resources have been loaded */ });
// reload all
i18next.reloadResources();
// reload languages
i18next.reloadResources(['de', 'fr']);
示例5: de
});
const v: string = i18next.t('my.key');
// fix language to german
const de = i18next.getFixedT('de');
const z: string = de('myKey');
// or fix the namespace to anotherNamespace
const anotherNamespace = i18next.getFixedT(null, 'anotherNamespace');
const x: string = anotherNamespace('anotherNamespaceKey'); // no need to prefix ns i18n.t('anotherNamespace:anotherNamespaceKey');
i18next.changeLanguage('en', (err, t) => {
if (err) {
console.log('something went wrong loading', err);
return;
}
t('key'); // -> same as i18next.t
});
i18next.loadNamespaces('myNamespace', (err, t) => {
/* resources have been loaded */
});
i18next.loadNamespaces(['myNamespace1', 'myNamespace2'], (err, t) => {
/* resources have been loaded */
});
i18next.loadLanguages('de', (err, t) => {
/* resources have been loaded */
});
i18next.loadLanguages(['de', 'fr'], (err, t) => {