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


TypeScript TranslateService.setDefaultLang方法代码示例

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


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

示例1: constructor

    constructor(private translate: TranslateService){
        const userLang = navigator.language || navigator.userLanguage;
        const lang = userLang.match(/^\D{2}/)[0];
        switch (lang){
            case'ru':
                translate.setDefaultLang('ru');
                break;
            case 'en':
            default:
                translate.setDefaultLang('en');
        }

    }
开发者ID:Maxislav,项目名称:Atlas-Angular2,代码行数:13,代码来源:app.module.ts

示例2: constructor

 constructor(private translate: TranslateService, private cookie: CookieService, private balanceService: BalanceService) {
     this.translate.setDefaultLang('en');
     const language = this.cookie.get('language');
     if (language) {
         this.translate.use(language);
     }
 }
开发者ID:theirc,项目名称:balance.refugee.info,代码行数:7,代码来源:app.component.ts

示例3: constructor

    constructor(private translate: TranslateService,
                public dialog: MdDialog) {
        // 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:mattblang,项目名称:b4a,代码行数:8,代码来源:app.component.ts

示例4: selectLang

 selectLang(event: any, lang: string) {
   if (event !== null)
     event.preventDefault();
   // this language will be used as a fallback when a translation isn't found in the current language
   this.trans.setDefaultLang("en");
   // the lang to use, if the lang isn't available, it will use the current loader to get them
   this.trans.use(lang);
   // this.refreshText();
 }
开发者ID:moleisking,项目名称:SAM,代码行数:9,代码来源:app.component.ts

示例5: 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:raqu3l,项目名称:respond,代码行数:10,代码来源:app.component.ts

示例6: configureLanguage

 private configureLanguage() {
     // configure language for translation service
     let userLang = navigator.language.split("-")[0];
     userLang = /(de|en)/gi.test(userLang) ? userLang : "en";
     this._translateService.setDefaultLang("en");
     this._translateService.use(userLang).subscribe(
         () => {
             this._translationNotifierService.publishTranslationsLoaded();
         }
     );
 }
开发者ID:EduCaMa,项目名称:Showcase,代码行数:11,代码来源:app.component.ts

示例7: constructor

  constructor(
    public angularService: AngularService,
    public alertService: AlertService,
    public utilsService: UtilsService,
    public userService: UserService,
    public translateService: TranslateService) {

    // i18n configuration
    translateService.setDefaultLang(AppConfig.LANG);
    translateService.use(AppConfig.LANG);
  }
开发者ID:daniviles,项目名称:classpip-dashboard,代码行数:11,代码来源:app.component.ts

示例8: ngOnInit

	ngOnInit() {
		this.globalClickCallbackFn = this.renderer.listen(this.elementRef.nativeElement, 'click', (event: any) => {
			console.log("全局监听点击事件>" + event);
		});

		this.translate.addLangs(["zh", "en"]);
		this.translate.setDefaultLang('zh');

		const browserLang = this.translate.getBrowserLang();
		console.log("检测到的浏览器语言>" + browserLang);
		this.translate.use(browserLang.match(/zh|en/) ? browserLang : 'zh');
	}
开发者ID:RicoLiu,项目名称:LearningAngular2,代码行数:12,代码来源:app.component.ts

示例9: init

    public init(refreshView: () => void): void {
        console.debug("-- Registered Languages are: " + languages.join(", "));
        this.translate.setDefaultLang(defaultLanguage);
        this.translate.addLangs(additionalLanguages);

        let initLang = this.translate.getBrowserLang();
        if (languages.indexOf(initLang) === -1) {
            initLang = defaultLanguage;
        }
        this.translate.use(initLang);
        moment.locale(initLang);

        console.debug("-- Using Language " + this.translate.currentLang);
        this.refreshView = refreshView;
    }
开发者ID:metaxmx,项目名称:FridayNightBeer,代码行数:15,代码来源:language.service.ts

示例10: initializeTranslateServiceConfig

 initializeTranslateServiceConfig(lang) {
   //var userLang = compareLanguage.test(lang) ? lang : defaultLanguage;  
   this.translate.setDefaultLang(defaultLanguage);   
   this.translate.use(compareLanguage.test(lang) ? lang : defaultLanguage);
   
 }
开发者ID:GECOR,项目名称:gecor-generic-2016,代码行数:6,代码来源:app.component.ts


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