PolymerElements / app-localize-behavior

Polymer behaviour to help internationalize your application
48 stars 54 forks source link

How to use within a dom-repeat template #107

Open CarbonCollins opened 7 years ago

CarbonCollins commented 7 years ago

Description

Hi all,

not sure if this is meant to work or not but when I attempt to use the localize function within a dom-repeat template where the item object contains the key for the translation, as opposed to it being hard coded, the translation is not reflected on the screen and instead returns an empty sring

Expected outcome

The text next to the iron icon should be the translated string from locales.json (see example below)

Actual outcome

empty string is displayed next to iron icon (see example below)

Steps to reproduce

        <paper-listbox attr-for-selected="data-label" selected="[[page]]" fallback-selection="dash" selected-attribute="selected">
          <template is="dom-repeat" items="[[pages]]">
            <paper-icon-item data-label="[[item.page]]" role="option" on-tap="_handleMenuTap">
              <iron-icon icon="[[item.icon]]" slot="item-icon"></iron-icon>
              [[localize(item.name)]]
            </paper-icon-item>
          </template>
        </paper-listbox>

where item.name contains a valid key name within the locals.json file

Browsers Affected