Published using Google Docs
Errai i18n Approach
Updated automatically every 5 minutes

Errai i18n Approach

Proposed approach:

  1. Multiple message bundles
  1. Automatically add “errai-i18n.json” if one is present??
  2. @Bundle annotation declares additional bundles
  3. @Bundle points to a root JSON message bundle file
  4. The JSON file must exist and 0 or more translation files MAY exist
  5. Each blah.json (set of files) results in a Translation being created
  1. TranslationService to aggregate the Translations
  1. @ApplicationScoped
  2. Each Translation is added to the registry and aggregated
  1. When translating a template:
  1. Use the TranslationService to lookup i18n values from i18n keys
  1. Lookup is done using current Locale info
  1. Visit the Template element, find all translatable nodes
  1. If a node has a data-i18n-skip attribute, it is *not* translatable
  2. If a node has only text content, it is translatable
  3. If a node has a data-i18n-key attribute, it is translatable
  4. Once a translatable node is found, stop visiting down
  5. If a node has either placeholder or title attributes, then those attributes are translatable
  6. NOTE: solve the img src= problem (data-i18n-attributes=”[csv]”)
  1. For each translatable node,
  1. Generate translation key for node
  1. Look for data-i18n-key attribute
  2. If not found, generate key from text content
  3. Prefix key with template short name
  1. Lookup new value in TranslationService (might be HTML - how to make this safe?)
  2. Replace translatable node content with value from TranslationService
  3. 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