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


TypeScript TranslateService.get方法代碼示例

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


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

示例1: create

 async create(opts?: AlertOptions, toTranslate = ['message', 'title', 'subTitle']): Promise<Alert> {
   if (opts) {
     for (const key of toTranslate) {
       if (opts[key]) {
         opts[key] = await this.translate.get(opts[key]).toPromise();
       }
     }
     if (opts.buttons) {
       for (const button of opts.buttons as AlertButton[]) {
         if (button.text) {
           button.text = await this.translate.get(button.text).toPromise();
         }
       }
     }
     if (opts.inputs) {
       for (const input of opts.inputs) {
         if (input.placeholder) {
           input.placeholder = await this.translate.get(input.placeholder).toPromise();
         }
         if (input.label) {
           input.label = await this.translate.get(input.label).toPromise();
         }
       }
     }
   }
   return this.alertCtrl.create(opts);
 }
開發者ID:ifiske,項目名稱:iFiske,代碼行數:27,代碼來源:translate-alert-controller.ts

示例2: forkJoin

		this.httpManagerService.post('/json/user/lang', {'uid': this.getUid(), 'lang': key}).subscribe(res => {
			forkJoin(
				this.translateService.get(res.alert.content),
				this.translateService.get('FORM_BUTTON_CLOSE'))
			.subscribe(([msg, action]) => {
				let snackBarRef = this.snackBar.open(msg, action, {
					'duration': 5000
				});
			});
		});
開發者ID:openevocracy,項目名稱:openevocracy,代碼行數:10,代碼來源:language.service.ts

示例3: validateUserPassword

 validateUserPassword(newPassword, confirmPassword): boolean {
     let passwordEmptyFault = newPassword === '' && confirmPassword === '';
     let arePasswordsSame = newPassword === confirmPassword;
     if (passwordEmptyFault) {
         this.translate.get('app.profile.message.error.emptyPassword').subscribe(message => {
             this.util.presentModal(message);
         });
     } else if (!arePasswordsSame) {
         this.translate.get('app.profile.message.error.mismatchPassword').subscribe(message => {
             this.util.presentModal(message);
         });
     }
     return !passwordEmptyFault && arePasswordsSame;
 }
開發者ID:intasect,項目名稱:intalinx-mobile,代碼行數:14,代碼來源:user-service.ts

示例4: toastInfo

  /*
   * Displays an info message
   */
  toastInfo(reason?: string)
  {
    let message: string;
    let key: string;

    switch(reason)
    {
      case 'jobRegistered':
        key = 'TOASTR.INFO.JOB';
        break;
      case 'noResult':
        key = 'TOASTR.INFO.NORESULT';
        break;
      case'restartNeeded':
        key = 'TOASTR.INFO.RESTART';
        break;
      default:
        key = 'TOASTR.INFO.DEFAULT';
        break;
    }

    this.translateService.get(key).subscribe(
      value => {
        message = value;
      });

    this.toastr.info(message)
  }
開發者ID:jodogne,項目名稱:orthanc-explorer-2,代碼行數:31,代碼來源:app.component.ts

示例5: toastSetupError

 /*
  * Displays an error at setup
  */
 toastSetupError(code :number)
 {
   let key: string;
   switch(code)
   {
     case 1:
       key = 'TOASTR.SETUP.SQLERROR';
       break;
     case 2:
       key = 'TOASTR.SETUP.PATHERROR';
       break;
     case 4:
       key = 'TOASTR.SETUP.USERERROR';
       break;
     case 5:
       key = 'TOASTR.SETUP.USERERROR';
       break;
     case 6:
       key = 'TOASTR.SETUP.SETERROR';
       break;
     default:
       key = 'TOASTR.ERROR.DEFAULT';
   }
   let message: string
   this.translateService.get(key).subscribe(
     value => {
       message = value;
     });
   this.toastr.error(message);
 }
開發者ID:jodogne,項目名稱:orthanc-explorer-2,代碼行數:33,代碼來源:app.component.ts

示例6: ngOnInit

 ngOnInit() {
     this.funcImagePath = this.webAppSettingDataService.getImagePathMakeFunc();
     this.browserInfoList = [
         {
             downloadLink: 'https://www.google.com/chrome',
             name: 'chrome',
             displayName: 'Google Chrome'
         }, {
             downloadLink: 'https://www.mozilla.org/en/firefox/new',
             name: 'firefox',
             displayName: 'Mozilla Firefox'
         }, {
             downloadLink: 'https://support.apple.com/en-us/HT204416',
             name: 'safari',
             displayName: 'Apple Safari'
         }, {
             downloadLink: 'https://www.microsoft.com/en-us/windows/microsoft-edge',
             name: 'edge',
             displayName: 'Microsoft Edge'
         }, {
             downloadLink: 'https://whale.naver.com/en/',
             name: 'whale',
             displayName: 'Naver Whale'
         }
     ];
     this.i18nText$ = this.translateService.get('SUPPORT.INSTALL_GUIDE');
 }
開發者ID:young891221,項目名稱:pinpoint,代碼行數:27,代碼來源:browser-support-page.component.ts

示例7: toastWarning

  /*
   * Displays a warning message
   */
  toastWarning(reason?: string)
  {
    let key: string;
    switch(reason)
    {
      case 'accessDenied':
        key = 'TOASTR.WARNING.ACCESS';
        break;
      case 'noResult':
        key = 'TOASTR.WARNING.TIMEOUT';
        break;
      case 'timeout':
        key = 'TOASTR.WARNING.TIMEOUT';
        break;
      default:
        key = 'TOASTR.WARNING.DEFAULT';
        break;
    }

    let message: string;
    this.translateService.get(key).subscribe(
      value => {
        message = value;
      });

    this.toastr.warning(message)
  }
開發者ID:jodogne,項目名稱:orthanc-explorer-2,代碼行數:30,代碼來源:app.component.ts

示例8: setTimeout

 setTimeout(() => {
   translate.get('TEST').subscribe((res2: string) => {
     expect(res2).toEqual('TEST'); // because the loader is "pristine" as if it was never called
     expect(http.expectOne).toHaveBeenCalledTimes(1);
     done();
   });
 }, 10);
開發者ID:denniske,項目名稱:ngx-translate-multi-http-loader,代碼行數:7,代碼來源:multi-http-loader.spec.ts

示例9: it

  it('should be able to reset a lang', (done: Function) => {
    translate.use('en');
    spyOn(http, 'expectOne').and.callThrough();

    // this will request the translation from the backend because we use a static files loader for TranslateService
    translate.get('TEST').subscribe((res: string) => {
      expect(res).toEqual('This is a test');
      expect(http.expectOne).toHaveBeenCalledTimes(1);

      // reset the lang as if it was never initiated
      translate.resetLang('en');

      expect(translate.instant('TEST')).toEqual('TEST');

      // use set timeout because no request is really made and we need to trigger zone to resolve the observable
      setTimeout(() => {
        translate.get('TEST').subscribe((res2: string) => {
          expect(res2).toEqual('TEST'); // because the loader is "pristine" as if it was never called
          expect(http.expectOne).toHaveBeenCalledTimes(1);
          done();
        });
      }, 10);
    });

    // mock response after the xhr request, otherwise it will be undefined
    http.expectOne('/assets/i18n/en.json').flush({"TEST": "This is a test"});
  });
開發者ID:denniske,項目名稱:ngx-translate-multi-http-loader,代碼行數:27,代碼來源:multi-http-loader.spec.ts

示例10: handleError

	public handleError(raw: Response | any) {
		console.error(raw);
		// If server sends 401 'Unauthorized'
		if(_.has(raw, 'status') && raw.status == 401 && raw._body == 'Unauthorized') {
			// Delete token in local storage and redirect
			window.localStorage.removeItem('currentUser');
			this.router.navigate(['/login']);
			
			return Observable.throw(raw);
		}
		
		var error = raw.json();
		
		// Show alert component if alert object is part of the server response
		var self = this;
		if(_.has(error, 'alert')) {
			// First clear old alerts
			self.alert.clear();
			
			// Push new alert
			this.translate.get(error.alert.content, error.alert.vars).subscribe(str => {
				self.alert.alert(error.alert.type, str);
			});
		}
		
		return Observable.throw(error);
	}
開發者ID:openevocracy,項目名稱:openevocracy,代碼行數:27,代碼來源:http-manager.service.ts


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