Hello Everyone,
*Problem:*
- There is currently no standard way for handling translations of
templates that are compiled on the client side (using the Caramel client
library).
- This scenario was noted during the APIM Store migration where certain
components of the My Subscriptions page are rendered on the client side.
*Suggestion*
-
*Changes to Caramel Client Library *
- The Caramel client side library uses Handlebars to generate templates
. The Handlebars library supports user defined helpers, that
execute logic
when a compiled template is executed. A helper will be registered which
will mirror the t notation found on the server side templates used by
Caramel.
- The helper function will internally invoke one of the client side
internalization frameworks listed below to handle the translation
-
*Changes to Caramel *
- A new field property ('translations') for caramel resource helpers
which will allow translation files to be loaded with a partial or page
- When a partial is requested by the Caramel Client side framework it
will check for related translation files with the same name (e.g.
<language_name>-<partial_name>.json)
- Only the translation file for the requested language will be
returned
- *Improvements to Caramel translation model*
- The translation mappings used by Caramel currently consists of a
single json file which maps the words to be translated
- As an improvement to aid in the main goal of this proposal , each page
(or partial) should have its own translation file.
- Further each language should have its own translation file (e.g.
sinhala-<partial_name>.json)
- Common words should be moved to a global translation file which will
automatically be included for each page
*Existing client side translation frameworks:*
I have compiled a list of possible client side internationalization
frameworks that could be used in the client side Handlebars helper. All of
the following frameworks support pluralization and client side caching.
- *i18next*, http://i18next.com/
- *JSPeranto,* https://github.com/jpjoyal/jsperanto
- *LocalePlanet,* http://www.localeplanet.com/index.html
- *MessageFormat,* https://github.com/SlexAxton/messageformat.js
- *Jed*, http://slexaxton.github.io/Jed/
*Some notable "Hick-ups" with the proposed solution*
- In addition to the partial an extra file will need to be fetched by
the Caramel client side library
Thank You,
Sameera
Sameera Medagammaddegedara
Software Engineer
Contact:
Email: [email protected]
Mobile: + 94 077 255 3005
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture