Published using Google Docs
Report abuse
Learn more
Errai i18n Approach
Updated automatically every 5 minutes
Errai i18n Approach
Proposed approach:
Multiple message bundles
Automatically add “errai-i18n.json” if one is present??
@Bundle annotation declares additional bundles
@Bundle points to a root JSON message bundle file
The JSON file must exist and 0 or more translation files MAY exist
Each blah.json (set of files) results in a Translation being created
TranslationService to aggregate the Translations
@ApplicationScoped
Each Translation is added to the registry and aggregated
When translating a template:
Use the TranslationService to lookup i18n values from i18n keys
Lookup is done using current Locale info
Visit the Template element, find all translatable nodes
If a node has a data-i18n-skip attribute, it is
*not*
translatable
If a node has
only
text content, it is translatable
If a node has a data-i18n-key attribute, it is translatable
Once a translatable node is found, stop visiting down
If a node has either
placeholder
or
title
attributes, then those attributes are translatable
NOTE: solve the img src= problem (data-i18n-attributes=”[csv]”)
For each translatable node,
Generate translation key for node
Look for data-i18n-key attribute
If not found, generate key from text content
Prefix key with template short name
Lookup new value in TranslationService (might be HTML - how to make this safe?)
Replace translatable node content with value from TranslationService
Use current locale to lookup new value - from most to least specific (e.g. look first in
_de_DE
,
then look in
_de
, then look in root).
Usage Notes
Need an automatic way to exclude some content from translation candidacy.
If an element has no children (text-only)
and
has a data-field attribute, it should probably not be translated
Problem getting jtidy to be on the classpath when running in Eclipse hosted mode
Would be nice to be able to inject the translation service
Useful when formatting dates/numbers in dynamic content
Provides a way to use the translation service without using templates? Directly to fields perhaps?
Also pull in errai-bundle.json standard bundle file(s)
Use IDs for i18n keys (and data-field attributes)
Share visit/traverse algorithm between runtime and compile time