0

Localization behavior is working fine for me, but i don't know if i can use it in a ready function and how.

If I use {{localize('greeting')}} in html, Its working fine. But I need to use through function

initErrorMessage: function(loc) {
  return localize(loc);
},

And I need to use in property as well.

datePickerRangeArray: {
    type: Array,
    value: function() {
      return [
        {"key": "!h8", "val": this.localize('last8hrs')},
        {"key": "!h12", "val": this.localize('last12hrs')},
        {"key": "!h24", "val": this.localize('last24hrs')},
        {"key": "!h168", "val": this.localize('last48hrs')},
        {"key": "current-day", "val": this.localize('CurrentDay')},
        {"key": "previous-day", "val": this.localize('PreviousDay')}];
    }
  }

I am getting error on this. How to achieve this. Thanks in advance.

a1626
  • 2,953
  • 1
  • 19
  • 34
YOLO
  • 3
  • 1

2 Answers2

0

Prefer using it in attached instead of ready as Polymer does not guarantee attributes', children's availability in ready callback.

a1626
  • 2,953
  • 1
  • 19
  • 34
0

Use this.async function and initialize with empty object and add localization in attached function with async function.

datePickerRangeArray: {
    type: Array,
    value: {}
  }


attached: function(){
   this.async(function(){
     datePickerRangeArray = [
        {"key": "!h8", "val": this.localize('last8hrs')},
        {"key": "!h12", "val": this.localize('last12hrs')},
        {"key": "!h24", "val": this.localize('last24hrs')},
        {"key": "!h168", "val": this.localize('last48hrs')},
        {"key": "current-day", "val": this.localize('CurrentDay')},
        {"key": "previous-day", "val": this.localize('PreviousDay')}];
    },10);   
}
Ananth A
  • 331
  • 2
  • 5