0

Is it possible to call a translation dynamically using interpolation in a template? I'd like to get something like that from this version:

<label for="{{media.type}}">{{t 'social.labels.twitter'}}</label>

to the below one using interpolation:

<label for="{{media.type}}">{{t 'social.labels.'{{model.some_media_name}}}}</label>

As you see, I' like to call a label translation for a specified social media based on its model value. The above snippet does not work. Any ideas ? Thank you

belgoros
  • 3,590
  • 7
  • 38
  • 76

1 Answers1

0

I fond the answer at one of ember-i18n issues, you should just use concat function as follows:

<label for="{{media.type}}">{{t (concat "social.labels." media.type)}}</label>

What will look for a translation key social.labels.twiiter in case of media.type equals to twitter.

belgoros
  • 3,590
  • 7
  • 38
  • 76