当前位置: 首页>>代码示例>>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;未经允许,请勿转载。