Let's say I have the following translation code:

languageOptions: {
  en: {
    code: "en"
    displayName: "English"
  },
  es: {
    code: "es"
    displayName: "Español"
  }
}

I want to, from within my Handlebars template, iterate over the properties within languageOptions. I'm also using the ember-i18n plugin. Is there a way to do something like what I'm attempting to do here? (The code below, unfortunately, does not work.)

{{#each-in (t 'languageOptions') as | language | }}
    {{language}}
{{/each-in}}
3

There are 3 best solutions below

0
eddz On

I think a plain {{each}}, translating the text from within the loop, should give you the result you are looking for.

{{#each languageOptions as |language|}}
    {{t language.displayName}}
{{/each}}
0
Ebrahim Pasbani On

You can not use like this. Because t helper returns string. You need to create a helper to return a plain object from your translations files

0
acorncom On

Check this wiki page (https://github.com/jamesarosen/ember-i18n/wiki/Example:-Language-Chooser), it shows how to do what you are after ...