本文整理汇总了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));
}