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


TypeScript core.TranslateService類代碼示例

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


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

示例1: constructor

    constructor(
        private translate: TranslateService,
        private cookie: CookieService,
        private session: SessionService,
        private appConfigService: AppConfigService,
        private titleService: Title) {
        // Override page title
        let key: string = "APP_TITLE.HARBOR";
        if (this.appConfigService.isIntegrationMode()) {
            key = "APP_TITLE.REG";
        }

        translate.get(key).subscribe((res: string) => {
            this.titleService.setTitle(res);
        });
    }
開發者ID:reasonerjt,項目名稱:harbor,代碼行數:16,代碼來源:app.component.ts

示例2: constructor

    constructor(viewContainerRef: ViewContainerRef,
                private renderer: Renderer,
                private router: Router,
                private translate : TranslateService) {
        this.viewContainerRef = viewContainerRef;
        translate.addLangs(["ru", "cz", "en"]);
        translate.setTranslation("ru", RU);
        translate.setTranslation("en", EN);
        translate.setTranslation("cz", CZ);
        translate.setDefaultLang('ru');

        let browserLang = translate.getBrowserLang();
        translate.use(browserLang.match(/ru/) ? browserLang : 'ru');
    }
開發者ID:pozitivity,項目名稱:demo,代碼行數:14,代碼來源:app.component.ts

示例3: getRecommendationLabel

    public getRecommendationLabel(motion: MotionBlockSlideMotionRepresentation): string {
        let recommendation = this.translate.instant(motion.recommendation.name);
        if (motion.recommendation_extension) {
            const extension = motion.recommendation_extension.replace(/\[motion:(\d+)\]/g, (match, id) => {
                const titleInformation = this.data.data.referenced_motions[id];
                if (titleInformation) {
                    return this.motionRepo.getIdentifierOrTitle(titleInformation);
                } else {
                    return this.translate.instant('<unknown motion>');
                }
            });

            recommendation += ' ' + extension;
        }
        return recommendation;
    }
開發者ID:jwinzer,項目名稱:OpenSlides,代碼行數:16,代碼來源:motion-block-slide.component.ts

示例4: textToDocDef

    /**
     * Creates pdfmake definitions for basic information about the motion and
     * comments or notes
     *
     * @param note string optionally containing html layout
     * @param motion the ViewMotion this note refers to
     * @param noteTitle additional heading to be used (will be translated)
     * @returns pdfMake definitions
     */
    public textToDocDef(note: string, motion: ViewMotion, noteTitle: string): object {
        const title = this.createTitle(motion);
        const subtitle = this.createSubtitle(motion);
        const metaInfo = this.createMetaInfoTable(
            motion,
            this.configService.instant('motions_recommendation_text_mode'),
            ['submitters', 'state', 'category']
        );
        const noteContent = this.htmlToPdfService.convertHtml(note);

        const subHeading = {
            text: this.translate.instant(noteTitle),
            style: 'heading2'
        };
        return [title, subtitle, metaInfo, subHeading, noteContent];
    }
開發者ID:jwinzer,項目名稱:OpenSlides,代碼行數:25,代碼來源:motion-pdf.service.ts

示例5: delete

    /**
     * Delete a file from the list.
     *
     * @param {number} index The index of the file.
     * @param {boolean} [askConfirm] Whether to ask confirm.
     */
    delete(index: number, askConfirm?: boolean): void {
        let promise;

        if (askConfirm) {
            promise = this.domUtils.showConfirm(this.translate.instant('core.confirmdeletefile'));
        } else {
            promise = Promise.resolve();
        }

        promise.then(() => {
            // Remove the file from the list.
            this.files.splice(index, 1);
        }).catch(() => {
            // User cancelled.
        });
    }
開發者ID:jleyva,項目名稱:moodlemobile2,代碼行數:22,代碼來源:attachments.ts

示例6: exportCallList

 /**
  * Exports the call list.
  *
  * @param motions All motions in the CSV. They should be ordered by callListWeight correctly.
  */
 public exportCallList(motions: ViewMotion[]): void {
     this.csvExport.export(
         motions,
         [
             { label: 'Called', map: motion => (motion.sort_parent_id ? '' : motion.identifierOrTitle) },
             { label: 'Called with', map: motion => (!motion.sort_parent_id ? '' : motion.identifierOrTitle) },
             { label: 'submitters', map: motion => motion.submitters.map(s => s.short_name).join(',') },
             { property: 'title' },
             {
                 label: 'recommendation',
                 map: motion => (motion.recommendation ? this.motionRepo.getExtendedRecommendationLabel(motion) : '')
             },
             { property: 'motion_block', label: 'Motion block' }
         ],
         this.translate.instant('Call list') + '.csv'
     );
 }
開發者ID:CatoTH,項目名稱:OpenSlides,代碼行數:22,代碼來源:motion-csv-export.service.ts

示例7: setMotionBlock

 /**
  * Opens a dialog and changes the motionBlock for all given motions.
  *
  * @param motions The motions for which to change the motionBlock
  */
 public async setMotionBlock(motions: ViewMotion[]): Promise<void> {
     const title = this.translate.instant('This will set the following motion block for all selected motions:');
     const clearChoice = 'Clear motion block';
     const selectedChoice = await this.choiceService.open(
         title,
         this.motionBlockRepo.getViewModelList(),
         false,
         null,
         clearChoice
     );
     if (selectedChoice) {
         for (const motion of motions) {
             const blockId = selectedChoice.action ? null : (selectedChoice.items as number);
             await this.repo.update({ motion_block_id: blockId }, motion);
         }
     }
 }
開發者ID:jwinzer,項目名稱:OpenSlides,代碼行數:22,代碼來源:motion-multiselect.service.ts

示例8: resolve

 handler: data => {
   if (data.newPassword.length < 6) {
     this.meuToastService.present(this.translateService.instant('CHANGE_PASSWORD.ERROR'));
     return false;
   }
   this.authService.updatePassword(email, currentPassword, data.newPassword)
 .then(
   () => {
     this.meuToastService.present(this.translateService.instant('CHANGE_PASSWORD.SUCCESS'));
     resolve();
   }
 )
 .catch(err => {
   this.meuToastService.present(this.translateService.instant('COMMON_ERROR'));
   reject();
 });
 }
開發者ID:meumobi,項目名稱:infomobi,代碼行數:17,代碼來源:login.ts

示例9: setLanguage

	// @desc: Set language by lang key, done after user interaction
	public setLanguage(key) {
		// Update language
		this.translateService.use(key);
		// Set/Update language in local storage for later use
		localStorage.setItem('language', key);
		// Update user language to server
		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,代碼行數:18,代碼來源:language.service.ts

示例10: initErrorMessages

    /**
     * Initialize some common errors if they aren't set.
     */
    protected initErrorMessages(): void {
        this.errorMessages = this.errorMessages || {};

        this.errorMessages.required = this.errorMessages.required || this.translate.instant('core.required');
        this.errorMessages.email = this.errorMessages.email || this.translate.instant('core.login.invalidemail');
        this.errorMessages.date = this.errorMessages.date || this.translate.instant('core.login.invaliddate');
        this.errorMessages.datetime = this.errorMessages.datetime || this.translate.instant('core.login.invaliddate');
        this.errorMessages.datetimelocal = this.errorMessages.datetimelocal || this.translate.instant('core.login.invaliddate');
        this.errorMessages.time = this.errorMessages.time || this.translate.instant('core.login.invalidtime');
        this.errorMessages.url = this.errorMessages.url || this.translate.instant('core.login.invalidurl');

        // Set empty values by default, the default error messages will be built in the template when needed.
        this.errorMessages.max = this.errorMessages.max || '';
        this.errorMessages.min = this.errorMessages.min || '';
    }
開發者ID:SATS-Seminary,項目名稱:moodlemobile2,代碼行數:18,代碼來源:input-errors.ts


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