本文整理汇总了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);
});
}
示例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');
}
示例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;
}
示例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];
}
示例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.
});
}
示例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'
);
}
示例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);
}
}
}
示例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();
});
}
示例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
});
});
});
}
示例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 || '';
}