本文整理汇总了TypeScript中i18next.loadLanguages函数的典型用法代码示例。如果您正苦于以下问题:TypeScript loadLanguages函数的具体用法?TypeScript loadLanguages怎么用?TypeScript loadLanguages使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了loadLanguages函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: anotherNamespace
// 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']);
// reload namespaces for all languages
i18next.reloadResources(null, ['ns1', 'ns2']);
// reload namespaces in languages
i18next.reloadResources(['de', 'fr'], ['ns1', 'ns2']);
// for current language
示例2: 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) => {
/* resources have been loaded */
});
// reload all
i18next.reloadResources();
// reload languages
i18next.reloadResources(['de', 'fr']);
// reload namespaces for all languages
i18next.reloadResources(null, ['ns1', 'ns2']);
// reload namespaces in languages