當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript TranslateService.use方法代碼示例

本文整理匯總了TypeScript中ng2-translate.TranslateService.use方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TranslateService.use方法的具體用法?TypeScript TranslateService.use怎麽用?TypeScript TranslateService.use使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ng2-translate.TranslateService的用法示例。


在下文中一共展示了TranslateService.use方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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

示例2: 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

示例3: constructor

  constructor(public translate: TranslateService, private auth: Auth) {
    this.menuItems = ROUTES;
        // use navigator lang if available
        var userLang = navigator.language.split('-')[0];
        userLang = /(de|en)/gi.test(userLang) ? userLang : 'en';

        // this trigger the use of the german or english language after setting the translations
        translate.use(userLang);
  }
開發者ID:mloDev,項目名稱:DfBuilder,代碼行數:9,代碼來源:navbar.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: switchLanguage

 public switchLanguage(lang: string): void {
     if (lang === this.translate.currentLang) {
         return; // No Change
     }
     if (languages.indexOf(lang) === -1) {
         console.warn("Cannot change language to: " + lang + " (language is not registered)");
         return;
     }
     this.translate.use(lang).subscribe(() => {
         console.debug("-- Using Language " + this.translate.currentLang);
         moment.locale(lang);
         this.refreshView();
     })
 }
開發者ID:metaxmx,項目名稱:FridayNightBeer,代碼行數:14,代碼來源:language.service.ts

示例10: 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


注:本文中的ng2-translate.TranslateService.use方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。