Reputation: 1521
I'm using angular-translate module for translation, but i have dynamic string which doesn't get translated.
I have tried this ways:
{{ data.foo | translate }}
This didn't work.
And i tried using his own directive:
<span translate>{{ data.foo }}</span>
Using this method i get in output result of data.foo without translation.
What is the best way to do this?
Thanks :)
Upvotes: 3
Views: 10606
Reputation: 5290
You must not have the translationProvider configured correctly. You should have something like this in your config:
$translateProvider.translations({
'TRANSLATEME': 'Here is the translation'
});
and data.foo needs to equal TRANSLATEME
.
Here's a Plunker showing it working.
Upvotes: 3
Reputation: 14440
Do you have a string matching a translation key in data.foo ? is so :
<span translate="{{data.foo}}"></span>
definitely works; as well as :
<span>{{ data.foo | translate}}</span>
Upvotes: 0