本文整理汇总了TypeScript中ng2-translate.TranslateService.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TranslateService.get方法的具体用法?TypeScript TranslateService.get怎么用?TypeScript TranslateService.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ng2-translate.TranslateService
的用法示例。
在下文中一共展示了TranslateService.get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: sendContactForm
sendContactForm() {
if (!this.myForm.dirty && !this.myForm.valid)
this.trans.get("FormNotValid").subscribe((res: string) => this.message = res);
else {
this.trans.get("MessagesContactUsSending").subscribe((res: string) => this.message = res);
this.web.sendContactForm(this.myForm.value).subscribe(
data => this.trans.get("MessagesSent").subscribe((res: string) => this.message = res),
error => this.trans.get("MessagesSentContactUsError").subscribe((res: string) => this.message = res),
() => this.trans.get("DoneContactUs").subscribe((res: string) => console.log(res))
);
}
}
示例2: login
login() {
if (!this.myForm.dirty && !this.myForm.valid)
this.trans.get("FormNotValid").subscribe((res: string) => this.message = res);
else {
this.trans.get("UserSentLoggedIn").subscribe((res: string) => this.message = res);
this.auth.login(this.myForm.value).subscribe(
() => this.router.navigate(["/dashboard"]),
error => this.trans.get("LoginNotPossible").subscribe((res: string) => this.message = res + error),
() => this.trans.get("DoneContactUs").subscribe((res: string) => console.log(res))
);
}
}
示例3: constructor
// Create instances off the data service and router service.
constructor(private fruitService: FruitService, private router: Router, private translate: TranslateService) {
const _router = this.router;
// Instanciate and populate the dynamic columns array.
// this.gridcols = new Array<wjcGrid.Column>();
// this.gridcols.push(new wjcGrid.Column(({ header: 'Name', binding: 'common_name', width: 400 })));
// this.gridcols.push(new wjcGrid.Column(({ header: 'Species', binding: 'species', width: 100 })));
// this.gridcols.push(new wjcGrid.Column(({ header: 'Region', binding: 'region', width: 100 })));
// this.gridcols.push(new wjcGrid.Column(({ header: 'Image', binding: 'ImageURL', width: 100 })));
// Configure the Bento Toolbar with sample data.
this.toolbarConfigurationData = [
{
label: 'Add',
icon: 'bento-icon-add',
action: () => {
console.log('add');
}
}, {
label: 'Import',
icon: 'bento-icon-enter',
action: () => {
console.log('import');
}
}, {
label: 'Export',
icon: 'bento-icon-exit',
action: () => {
console.log('export');
}
}, {
label: 'Delete',
icon: 'bento-icon-close-circle',
action: () => {
console.log('delete');
}
},
{
// Vendor Button
label: 'Vendors',
icon: '',
action: () => {_router.navigate(['fruit-vendor']);}
}];
translate.get('Common.Add').subscribe((res) => this.toolbarConfigurationData[0].label = res);
translate.get('Common.Import').subscribe((res) => this.toolbarConfigurationData[1].label = res);
translate.get('Common.Export').subscribe((res) => this.toolbarConfigurationData[2].label = res);
translate.get('Common.Delete').subscribe((res) => this.toolbarConfigurationData[3].label = res);
translate.get('Fruit.List.Vendors').subscribe((res) => this.toolbarConfigurationData[4].label = res);
}
示例4: constructor
constructor(private _store: Store<State>,
private _translateService: TranslateService) {
this._translateService
.get("GENERIC_NO-RECORDS-FOUND")
.subscribe(value => this.emptyListMessage = value);
}
示例5: translate
private translate(message: string): string {
let translation: string;
this.translateService.get(message).subscribe(
data => translation = data
);
return translation;
}
示例6: show
show(key: string, useAsIs = false) {
if (!useAsIs) {
this.translateService.get(key).subscribe(text => this.actuallyShow(text));
}
else {
this.actuallyShow(key);
}
}
示例7: getTranslatedString
getTranslatedString(data: any) {
this.translateService.get(data).subscribe(
(value: any) => {
this.translatedResponse = value;
}
);
return this.translatedResponse;
}
示例8: send
send() {
if (!this.myForm.dirty && !this.myForm.valid)
this.trans.get("FormNotValid").subscribe((res: string) => this.message = res);
else {
this.user.forgottenpassword(this.myForm.value).subscribe(
data => this.trans.get("PasswordSend").subscribe((res: string) => this.message = res),
error => this.trans.get("ErrorSendingEmail").subscribe((res: string) => this.message = res),
() => this.trans.get("DoneForgottenPassword").subscribe((res: string) => console.log(res))
);
}
}
示例9: changeForgottenPassword
changeForgottenPassword(passwordForm: ChangePasswordModel): Observable<any> {
if (passwordForm.newpassword !== passwordForm.confirmpassword) {
let errorMsg: string;
this.trans.get("ConfirmPasswordSame").subscribe((res: string) => errorMsg = res);
return Observable.throw(errorMsg);
}
let body =
"oldpassword=" + passwordForm.oldpassword +
"&newpassword=" + passwordForm.newpassword +
"&confirmpassword=" + passwordForm.confirmpassword;
let headers = new Headers();
headers.append("Content-Type", "application/x-www-form-urlencoded");
return this.http.post(Settings.backend_url + "/changeforgottenpassword?locale=" + this.trans.currentLang, body,
{ headers: headers }).catch(this.handleError);
}
示例10: transform
transform(elements: any): any[] {
if (!elements) return [];
let translations = [];
for (let i = 0; i < elements.length; i++) {
translations.push(elements[i].id);
}
this.translateService.get(translations, {}).subscribe((texts) => {
for (let i = 0; i < elements.length; i++) {
elements[i].translation = texts[elements[i].id];
}
});
return elements.sort(function(a, b){
if(a.translation < b.translation) return -1;
if(a.translation > b.translation) return 1;
return 0;
});
}