本文整理匯總了TypeScript中ng2-translate/ng2-translate.TranslateService.get方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TranslateService.get方法的具體用法?TypeScript TranslateService.get怎麽用?TypeScript TranslateService.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ng2-translate/ng2-translate.TranslateService
的用法示例。
在下文中一共展示了TranslateService.get方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: updateTitle
/**
* update the window title using params in the following
* precendence
* 1. titleKey parameter
* 2. $state.$current.data.pageTitle (current state page title)
* 3. 'global.title'
*/
updateTitle(titleKey?: string) {
if (!titleKey && this.$state.current.data && this.$state.current.data.pageTitle) {
titleKey = this.$state.current.data.pageTitle;
}
this.translateService.get(titleKey || 'global.title').subscribe(title => {
window.document.title = title;
});
}
示例2: updateTitle
/**
* Update the window title using params in the following
* order:
* 1. titleKey parameter
* 2. $state.$current.data.pageTitle (current state page title)
* 3. 'global.title'
*/
updateTitle(titleKey?: string) {
if (!titleKey) {
titleKey = this.getPageTitle(this.router.routerState.snapshot.root);
}
this.translateService.get(titleKey).subscribe(title => {
this.titleService.setTitle(title);
});
}
示例3: updateTitle
/**
* update the window title using params in the following
* precendence
* 1. titleKey parameter
* 2. $state.$current.data.pageTitle (current state page title)
* 3. 'global.title'
*/
updateTitle(titleKey?: string) {
if (!titleKey && this.titleService.getTitle() ) {
titleKey = this.titleService.getTitle();
}
this.translateService.get(titleKey || 'global.title').subscribe(title => {
this.titleService.setTitle(title);
});
}
示例4: constructor
constructor(public translate: TranslateService, public storage: StorageService) {
this.translate.get("salute")
.subscribe(
(data) => {
console.log(`${data} from home.ts`);
},
(error) => {
console.log(error);
});
}
示例5: toast
toast(friendlyErrorMessageKey:string):void {
this.translate.get(friendlyErrorMessageKey).subscribe((message:string) => {
let nav:NavController = this.app.getActiveNav();
let toast:Toast = Toast.create({
message: message,
duration: message.length * 100 + 2000
});
nav.present(toast);
});
}
示例6: constructor
constructor(translate: TranslateService) {
var userLang = navigator.language.split('-')[0]; // use navigator lang if available
// this language will be used as a fallback when a translation isn't found in the current language
translate.setDefaultLang('en');
/*translate.setTranslation('en', {
"FOO": "foo worked"
});*/
// the lang to use, if the lang isn't available, it will use the current loader to get them
translate.use(userLang);
console.log(translate.get('THATITLE'), translate.get('FOO'));
}
示例7: ngOnInit
ngOnInit() {
this.translate.get(['_about.OMA', '_about.Founder', '_about.Manager', '_about.Analyst', '_about.Designer', '_about.Marketer', '_about.Editor', '_about.Developer', '_about.Tester', '_about.Support']).subscribe((t: string[]) => {
this.members = [
new TeamMember('Jacek Kościesza', t['_about.OMA'], 'http://www.ronbrauner.com/i/copywriter-multiple-personality.jpg'),
new TeamMember('Jacek Kościesza', t['_about.Founder'], 'https://media.licdn.com/mpr/mpr/shrinknp_200_200/AAEAAQAAAAAAAAbJAAAAJGM3MDMwMTA5LWUzYmQtNGFiYy1hOWJiLTI1MjBjNDE0OWFhNQ.jpg'),
new TeamMember('Jacek Kościesza', t['_about.Manager'], 'https://static.goldenline.pl/user_photo/250/user_1571834_4133dd_huge.jpg'),
new TeamMember('Jacek Kościesza', t['_about.Analyst'], 'https://static.goldenline.pl/user_photo/250/user_1571834_4133dd_huge.jpg'),
new TeamMember('Jacek Kościesza', t['_about.Designer'], 'https://static.goldenline.pl/user_photo/250/user_1571834_4133dd_huge.jpg'),
new TeamMember('Jacek Kościesza', t['_about.Marketer'], 'https://static.goldenline.pl/user_photo/250/user_1571834_4133dd_huge.jpg'),
new TeamMember('Jacek Kościesza', t['_about.Editor'], 'https://static.goldenline.pl/user_photo/250/user_1571834_4133dd_huge.jpg'),
new TeamMember('Jacek Kościesza', t['_about.Developer'], 'https://static.goldenline.pl/user_photo/250/user_1571834_4133dd_huge.jpg'),
new TeamMember('Jacek Kościesza', t['_about.Tester'], 'https://static.goldenline.pl/user_photo/250/user_1571834_4133dd_huge.jpg'),
new TeamMember('Jacek Kościesza', t['_about.Support'], 'https://static.goldenline.pl/user_photo/250/user_1571834_4133dd_huge.jpg')
]
});
}
示例8: constructor
constructor(public translate: TranslateService, public mdIconRegistry: MdIconRegistry) {
console.log('entra a constructor');
this.translate.get("salute")
.subscribe(
(data) => {
console.log(data + " from home.ts");
},
(error) => {
console.log(error);
});
// mdIconRegistry
// .addSvgIcon('thumb-up', '/demo-app/icon/assets/thumbup-icon.svg')
// .addSvgIconSetInNamespace('core', '/demo-app/icon/assets/core-icon-set.svg')
// .registerFontClassAlias('fontawesome', 'fa');
// mdIconRegistry
// .addSvgIconSetInNamespace('core', 'material/css/materialdesignicons.min.css');
}
示例9: get
get(key: string, interpolateParams: any): Observable<string> {
return this.translate.get(`validations.${key}`, interpolateParams);
}
示例10: ngOnInit
ngOnInit() {
this.translate.get('TITLE')
.subscribe(title => this.setTitle(title));
}