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


TypeScript TranslateService.setDefaultLang方法代码示例

本文整理汇总了TypeScript中ng2-translate/ng2-translate.TranslateService.setDefaultLang方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TranslateService.setDefaultLang方法的具体用法?TypeScript TranslateService.setDefaultLang怎么用?TypeScript TranslateService.setDefaultLang使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ng2-translate/ng2-translate.TranslateService的用法示例。


在下文中一共展示了TranslateService.setDefaultLang方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor

  constructor(translate: TranslateService) {
    let userLang = navigator.language.split('-')[0];
    userLang = /(es|en)/gi.test(userLang) ? userLang : 'en';

    translate.setDefaultLang('en');
    translate.use(userLang);
  }
开发者ID:antonioalf,项目名称:angular2-architecture,代码行数:7,代码来源:app.component.ts

示例2: constructor

  constructor(private translate: TranslateService, private titleService: Title) {
    // this language will be used as a fallback when a translation isn't found in the current language
    translate.setDefaultLang('en');

    // the lang to use, if the lang isn't available, it will use the current loader to get them
    translate.use('en');
  }
开发者ID:yang-xiaodong,项目名称:AspNetCoreSpa,代码行数:7,代码来源:app.component.ts

示例3: constructor

	/** Sets the app language. */
	constructor(
		private translate: TranslateService,
		private authService: AuthService
	) {
		translate.setDefaultLang('en');
		translate.use('pt');
	}
开发者ID:andregs,项目名称:think-before-voting,代码行数:8,代码来源:app.component.ts

示例4: constructor

  constructor(translate: TranslateService) {
    var userLang = navigator.language.split('-')[0];
    userLang = /(cs|en)/gi.test(userLang) ? userLang : 'cs';

    // jazyk, který se použije pokud nebude jazyk automaticky detekován
    translate.setDefaultLang('cs');

    translate.use(userLang);
  }
开发者ID:ohweb,项目名称:czech-atlantic-row-web,代码行数:9,代码来源:app.component.ts

示例5: constructor

     constructor(private navController: NavController,
        private platform:Platform,public storageProvider:StorageProvider,
        public fbProvider:FbProvider, public kakaoProvider:KakaoProvider,
        public emailProvider:EmailProvider,private nativeStorage: NativeStorage,private app:App,
        private translateService:TranslateService, private splashScreen: SplashScreen){

         console.log("ErrorPage constructor");
         //this.android_platform=this.platform.is('android');
         //this.reason=this.storageProvider.errorReason;

        if(!navigator.language.startsWith("ko")){
            translateService.setDefaultLang('en');
            translateService.use('en');
        }else{
            translateService.setDefaultLang('ko');
            translateService.use('ko');
        }
     }
开发者ID:raceyi,项目名称:takit,代码行数:18,代码来源:error.ts

示例6: ngOnInit

  public ngOnInit(): void {

    // Set Language
    this.translate.setDefaultLang('en');
    this.translate.setTranslation('en', require('./../assets/i18n/en.json'));

    // Print configuration to console
    console.log('App config: ', AppConfig);
  }
开发者ID:Tyderion,项目名称:ng2-seed,代码行数:9,代码来源:app.ts

示例7: constructor

  constructor(private _translate: TranslateService) {
        var userLang = navigator.language.split('-')[0]; // use navigator lang if available
        userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';

         // this language will be used as a fallback when a translation isn't found in the current language
        _translate.setDefaultLang('en');
        
         // the lang to use, if the lang isn't available, it will use the current loader to get them
        _translate.use(userLang);
    }
开发者ID:Rambou,项目名称:respond,代码行数:10,代码来源:app.component.ts

示例8: constructor

	constructor(
		translate: TranslateService,
		router: Router
	) {
		translate.setTranslation('en', require('../translations/locale-en.json'));
		translate.setDefaultLang('en');
		translate.use('en');

		router.navigate(['/home']);
	}
开发者ID:peterbakonyi05,项目名称:electron-angular2-app-skeleton,代码行数:10,代码来源:app.ts

示例9: translateConfig

  translateConfig() {
    var userLang = navigator.language.split('-')[0]; // use navigator lang if available
    userLang = /(fr|en)/gi.test(userLang) ? userLang : 'fr';
 
    // this language will be used as a fallback when a translation isn't found in the current language
    this.translate.setDefaultLang('fr');
 
    // the lang to use, if the lang isn't available, it will use the current loader to get them
    this.translate.use(userLang);
  }  
开发者ID:gdessard,项目名称:handballStats,代码行数:10,代码来源:app.ts

示例10: constructor

  constructor(translate: TranslateService) {

    console.log('Environment config', Config);

    let userLang = navigator.language.split('-')[0];

    userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
    translate.setDefaultLang('en');
    translate.use(userLang);

  }
开发者ID:avatsaev,项目名称:angular2-seed,代码行数:11,代码来源:app.component.ts


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