本文整理匯總了TypeScript中ng2-translate/ng2-translate.TranslateService.instant方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TranslateService.instant方法的具體用法?TypeScript TranslateService.instant怎麽用?TypeScript TranslateService.instant使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ng2-translate/ng2-translate.TranslateService
的用法示例。
在下文中一共展示了TranslateService.instant方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getActionsConfig
getActionsConfig(startWorkoutHandler, saveWorkoutHandler) {
return {
title: this.translate.instant('WORKOUT_COMPLETE_ACTIONS_TITLE'),
buttons: [
{
text: this.translate.instant('WORKOUT_COMPLETE_START_WORKOUT'),
icon: !this.platform.is('ios') ? 'play' : null,
cssClass: 'Workout-start',
handler: () => {}
},
{
text: this.translate.instant('WORKOUT_COMPLETE_SAVE'),
icon: !this.platform.is('ios') ? 'list' : null,
cssClass: 'Workout-save',
handler: saveWorkoutHandler
},
{
text: this.translate.instant('WORKOUT_COMPLETE_CANCEL'),
role: 'cancel',
cssClass: 'Workout-cancel',
icon: !this.platform.is('ios') ? 'close' : null,
handler: () => {}
}
]
};
}
示例2: handleAPIError
/**
* This method handles the bad responses of the backend
* @param {Response} response Object with the server response
* @return {Observable<Response>} Response with the error message
*/
/* tslint:disable */
public handleAPIError(response: Response): Observable<any> {
/* tslint:enable */
let message: string = '';
let error: Error = Error.toObject(response.json().error);
console.error(error);
switch (error.status) {
case 401:
if (error.code === AppConfig.LOGIN_FAILED) {
message = this.translateService.instant('ERROR.LOGIN_FAILED');
}
else if (error.code === AppConfig.LOGIN_FAILED_EMAIL_NOT_VERIFIED) {
message = this.translateService.instant('ERROR.LOGIN_FAILED_EMAIL_NOT_VERIFIED');
} else {
// Unauthorized request (login again)
location.reload();
}
break;
case 500:
message = this.translateService.instant('ERROR.INTERNAL_ERROR') + error.message;
break;
default:
if (error.message) {
message = error.message;
} else {
message = this.translateService.instant('ERROR.INTERNAL_ERROR');
}
break;
}
return Observable.throw(message);
}
示例3:
this.freqObs = Observable.from(this.translate.getTranslation(Conf.lang).map(() => {
return [
{id: Freq.NONE, label: this.translate.instant('frequency.none')},
{id: Freq.DAILY, label: this.translate.instant('frequency.daily')},
{id: Freq.WEEKLY, label: this.translate.instant('frequency.weekly')},
// {id: Freq.BIWEEKLY, label: this.translate.instant('frequency.biweekly')},
{id: Freq.MONTHLY, label: this.translate.instant('frequency.monthly')},
// {id: Freq.BIMONTHLY, label: this.translate.instant('frequency.bimonthly')}
];
}).toPromise());
示例4: constructor
constructor(
public navController: NavController,
public translateService: TranslateService,
public utilsService: UtilsService,
public ionicService: IonicService,
public schoolService: SchoolService,
private loginService: LoginService) {
this.rootPage = HomePage;
this.homePage = new Page(HomePage, this.translateService.instant('HOME.TITLE'));
this.schoolPage = new Page(SchoolPage, this.translateService.instant('SCHOOL.TITLE'));
}
示例5: Notification
let esub = contextProvider.editingObservable.subscribe(editing => {
if(editing) {
if(this.editingNotification === undefined) {
this.editingNotification = new Notification('WARNING', translate.instant('edit.mode'));
}
this.notificationService.add('item', this.editingNotification);
}
});
示例6: showAlert
/**
* Displays an alert message with a confirmation button
* on the screen
* @param {string} title Title of the alert
* @param {string} message Message to display
*/
public showAlert(title: string, message: string): void {
this.alertCtrl.create({
title: title,
subTitle: message,
buttons: [this.translateService.instant('APP.OK')]
}).present(prompt);
}
示例7: createEditButton
createEditButton(message, handler) {
return {
text: this.translate.instant(message),
icon: !this.platform.is('ios') ? 'create' : null,
cssClass: 'WorkoutAction-edit',
handler
}
}
示例8: onDelete
/** Excludes this political party from the system. */
onDelete() {
const message = this.translate.instant('APP.CONFIRMATION');
const confirm = window.confirm(message);
if (confirm) {
this.partyService.remove(this.party).subscribe(
result => this.router.navigate(['/admin/party/list']),
error => this.router.navigate(['/error', error.status], { skipLocationChange: true })
);
}
}
示例9: ngOnInit
ngOnInit() {
if (this.postId) {
this.title = this.translate.instant('Edit Post');
this.postsService.getPost(this.postId)
.subscribe(res => {
this.form = this.fb.group({
id: res.id,
title: res.title,
contents: res.contents
})
})
} else {
this.title = this.translate.instant('Create Post');
this.form = this.fb.group({
title: '',
contents: ''
})
}
}