当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript i18next.changeLanguage函数代码示例

本文整理汇总了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');
     });
   });
 };
开发者ID:delphiactual,项目名称:DIM,代码行数:8,代码来源:settings.component.ts

示例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();
    });
开发者ID:w1cked,项目名称:DIM,代码行数:13,代码来源:settings.ts

示例3:

const changeLng = (lng: string) => {
    i18next.changeLanguage(lng);
};
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:3,代码来源:i18next-tests.ts

示例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']);
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:30,代码来源:i18next-tests.ts

示例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) => {
开发者ID:i18next,项目名称:i18next,代码行数:31,代码来源:init.test.ts


注:本文中的i18next.changeLanguage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。