With following:
prepareCaptions() {
this._translate.get([
'APP.PAGES.LOCOMOTIVE.PLACEHOLDER.TYPE.LEAD',
'APP.PAGES.LOCOMOTIVE.PLACEHOLDER.TYPE.LEAD_DOUBLE_TRACTION',
'APP.PAGES.LOCOMOTIVE.PLACEHOLDER.TYPE.LEAD_MULTIPLE_TRACTION',
'APP.PAGES.LOCOMOTIVE.PLACEHOLDER.TYPE.ADDITIONAL',
'APP.PAGES.LOCOMOTIVE.PLACEHOLDER.TYPE.ADDITIONAL_DOUBLE_TRACTION',
'APP.PAGES.LOCOMOTIVE.PLACEHOLDER.TYPE.ADDITIONAL_MULTIPLE_TRACTION'
])
.subscribe((translations: string[]) => {
this._applicationRepository.helper.tfzCaptions = translations;
})
}
where _translate is injected TranslateService in Ionic2 I just get the keys being bounced back :-(
Does it work with only loading 1 key? Seems like it can't find the translations at all.
Hi Sam,
yes translate.get('ERE.BE.A.TRNSLATION_KEY') works fine :-)
Best regards,
Kieran
From: Sam Verschueren [email protected]
Sent: Sunday, November 6, 2016 8:58:25 PM
To: ocombe/ng2-translate
Cc: Kieran Ryan; Author
Subject: Re: [ocombe/ng2-translate] translate.get with array of keys returns keys and not translation (#310)
Does it work with only loading 1 key? Seems like it can't find the translations at all.
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/ocombe/ng2-translate/issues/310#issuecomment-258706154, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AB_CQtbq3lauhlT4OpMBpYvebpcqfxUUks5q7jFhgaJpZM4KqP_s.
It seems to work perfectly fine in the plunker.
http://plnkr.co/edit/WoIeZeC9h0OVHQsrww6U
The result of the observable isn't an array though, it's an object. If you inspect that plunker you will notice that this call
translate.get(['HOME.TITLE', 'HOME.SELECT']).subscribe(res => {
console.log(res);
});
results in this object
{
"HOME.TITLE": "Hello Angular 2 with ng2-translate!",
"HOME.SELECT": "Change language"
}
Closing this as I believe it's just a type issue string[] Vs. {[key: string]: string}. Feel free to post new information if you believe my answer did not solve the problem.
Most helpful comment
It seems to work perfectly fine in the plunker.
http://plnkr.co/edit/WoIeZeC9h0OVHQsrww6U
The result of the observable isn't an array though, it's an object. If you inspect that plunker you will notice that this call
results in this object