Allow message keys to contain dots
See original GitHub issueBasically no Ember-related i18n library does allow dots in message keys, but I’ve found relying solely to Ember.get
a bit counter-intuitive. Granted, the implementation is simpler, since it’s a core Ember tool to fetch key paths and is working pretty well, but most of the i18n backeds use a key-value store like Redis. Therefore, when fetching the translations from the server, these messages must be un-flattened first to build up a hierarchical JS object structure, something Ember i18n libraries can deal with.
Instead, just serializing a KV table into
{
"product.info": "{product} will cost {price, number, EUR} if ordered by {deadline, date, time}",
"product.html.info": "<strong>{product}</strong> will cost <em>{price, number, EUR}</em> if ordered by {deadline, date, time}"
}
is much more straightforward on the server then the currently required
{
"product": {
"info": "{product} will cost {price, number, EUR} if ordered by {deadline, date, time}",
"html": {
"info": "<strong>{product}</strong> will cost <em>{price, number, EUR}</em> if ordered by {deadline, date, time}"
}
}
}
While the filesize is somewhat bigger by default, it is negligible when gzipped. Also, the former speeds up message lookups as a byproduct.
As these two semantics are not mutually exclusive (exact key lookup first, then fall back to Ember.get
), I see no disadvantage in supporting both.
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
As of 2.5.x,
ember g ember-intl-dot-notation
enables support for this w/o having to manually override internals.C’est magnifique 👍