本文整理匯總了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