當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。