Reputation: 902
First I will try to write down what I'm trying to do, then if you guys can't understand or actually need code to fully understand what I want, I will post a code example. I'm trying to translate a content using Angular Translate, but using a angular expression as the key. {{ 'key' | translate }} in this case, since I'm pulling information out of a service, then transfering that info into a controller so I can push into the html, I need to know if it's possible to do that.
so like,
{{ '{{product.productDetails}}' | translate }}
So in this case what's coming out of the product.producDetails would be some content, and that content would serve as a key to be translated depending upon the language selected by the person.
Anyways, Let me know if someone can help. Thanks Renan
Upvotes: 0
Views: 293
Reputation: 941
There is a syntax error.
Instead of
{{ '{{product.productDetails}}' | translate }}
just use this
{{ 'product.productDetails' | translate }}
and there should be json object which map the keys with the actual text messages and provide that json object to translateprovider and give translation name bellow is sample .
Example:
var englishTranslations = {'productDetails':'please enter product details'}
$translateProvider.translations('en', englishTranslations);
$translateProvider.preferredLanguage('en');
Upvotes: 1
Reputation: 37918
It even simpler than you thought:
{{ product.productDetails | translate }}
Here's working demo
Upvotes: 1