| Quaintous | Published: |
(tags)
|
(category)
|
|
| Updated: | ||||
| Polymer 1.0 Internationalization | ||||
IntroductionLet’s face it: internationalization is inevitable! As the importance of dynamic, client-side rendered web components increases, so does the need for a client-side i18n solution. In this article a simple component is introduced which asynchronously loads a translation file (in JSON) and provides other components with an tl;drGrab the code on gitlab or install it using Bower: now you can start using it in a custom element: note the renders to: ConsiderationsThe previous example assumes that fetching the translation file (i.e. The ElementWhy create an element at all when a simple behavior (which is a simple JS object) suffies? Well, I just wanted to comply with Polymer’s motto “there’s an element for that”. After all I believe that an element is the more elegant and readable way to do this task. Our element depends on When the element is imported it registers ConclusionThere are a number of other approaches all with the goal of providing internationalization for Polymer components. This approach follows Polymer’s “there’s an element for that” motto and introduces an element which loads translation files asynchronously and provides other elements with a behavior which can be used for translation. |
||||
| License: | ![]() |
🟢 No JavaScript | (Notes) | |
| 🟢 No Tracking | ||||
