本文整理匯總了TypeScript中ng2-translate/ng2-translate.TranslateService.getTranslation方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TranslateService.getTranslation方法的具體用法?TypeScript TranslateService.getTranslation怎麽用?TypeScript TranslateService.getTranslation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ng2-translate/ng2-translate.TranslateService
的用法示例。
在下文中一共展示了TranslateService.getTranslation方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: constructor
constructor(translate: TranslateService) {
this.appRoutes = APP_ROUTES;
let userLang: string = navigator.language.split('-')[0];
userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
translate.getTranslation(userLang);
translate.use(userLang);
}
示例2: constructor
constructor(private nav:NavController, navParams:NavParams, private agendaDao:AgendaDao, private error:ErrorService, private translate:TranslateService, private lessonService:LessonFormService, agendaService:AgendaService) {
let errKey = "global.error.init";
try {
this.entry = navParams.get('entry');
let start = navParams.get('start');
// Get live updates. Useful when the entry has been modified by a form, then we go back to this view.
agendaService.getFormattedEntry(this.entry.$key, start).subscribe((entry:AgendaEntry) => {
// console.log("AgendaDetailPage new entry:", entry);
this.entry = entry;
}, (err:any) => error.handler(err.code || errKey)(err));
this.removePopup = this.translate.getTranslation(Conf.lang).map(() => {
let confirm = Alert.create({
title: this.translate.instant('agenda.deleteConfirm.title'),
message: this.translate.instant('agenda.deleteConfirm.message'),
buttons: [
{text: this.translate.instant('alert.cancel')},
{
text: this.translate.instant('alert.confirm'),
handler: () => {
this.agendaDao.removeAgendaEntry(this.entry).then(() => {
confirm.dismiss().then(() => {
this.nav.pop();
});
}, (err:any) => this.error.handler(err.code || "lesson.error.remove")(err));
}
}
]
});
return confirm;
}).share();
} catch(err) {
this.error.handler(errKey)(err);
}
}
示例3: constructor
constructor(private translate:TranslateService) {
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());
this.freqObjObs = Observable.from(this.translate.getTranslation(Conf.lang).map(() => {
let m = new Map<number, string>();
m.set(Freq.NONE, this.translate.instant('frequency.none'));
m.set(Freq.DAILY, this.translate.instant('frequency.daily'));
m.set(Freq.WEEKLY, this.translate.instant('frequency.weekly'));
// m.set(Freq.BIWEEKLY, this.translate.instant('frequency.biweekly'));
m.set(Freq.MONTHLY, this.translate.instant('frequency.monthly'));
// m.set(Freq.BIMONTHLY, this.translate.instant('frequency.bimonthly'));
return m;
}).toPromise());
}