0

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

2 Answers 2

1

It even simpler than you thought:

{{ product.productDetails | translate }}

Here's working demo

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Aleksey L, that worked like a charm ;). totally simpler than I thought hehe.
1

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');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.