I used this method to translate my future website:

I created a HTML dictionnary and imported it (so it's loaded before Polymer 
renders the page):

<link id="localization" rel="import" href="dict.html"/>

dict.html:
  <translation>
  ...
      <key value="new">
          <val lang="en">New</val>
          <val lang="fr">Nouveau</val>
      </key>   
  ...  
  </translation> 

Then parsed this dictionnary as a document with javascript and used a 
Polymer expression to handle localization:
  ....
  PolymerExpressions.prototype.translate = function(key) {
    var dictkey = dictionnaries[key];
    return dictkey[currentLanguage]; 
  };

I only need to surround my main document with an autobinded template to get 
it translated:
<template is="auto-binding">
  <core-item label="{{translate('new')}}"></core-item>
</template>

I can also using it as an attribute for a polymer-element so.

I'm sure there's a best way to do it, but this one works like a charm for 
me.  


Le vendredi 15 novembre 2013 08:08:50 UTC+1, Nicolas Bouthors a écrit :
>
> Do we have à preferred approach to support internationalization of polymer 
> element. 
> For now I see using the binding API as an option, passing dictionaries as 
> a parameter to each element. But doing so is cumbersome for example for 
> elements containing other elements directly or via the content tag. 
>
> Any better idea? 
>
> Shouldn't we have a common way, so that all elements inherit from a common 
> dictionary and have some support to retrieve dictionary values from a 
> string, inside a mustache {{}}? 
>
>

Follow Polymer on Google+: plus.google.com/107187849809354688692
--- 
You received this message because you are subscribed to the Google Groups 
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/polymer-dev/2fc124e7-6822-454b-bb25-94065eb6e774%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to