How to get the key-value collection with the parent key?
Closed this issue · 2 comments
blood-romantic commented
if can get the key-value collection with the parent key via this.get(i18n).t("data.parent")
:
example:
data:{
parent : {
son1: "son1",
son2: "son2"
}
}
i wanna iterate it
jamesarosen commented
Locale.prototype.getCompiledTemplate
only compiles if the result is a String, so it would find the whole object for data.parent
. Unfortunately, it throws an assertion error if the looked up translation isn't a function. You could hack around this by doing
function parent() { return parent; }
parent.son1 = 'son1';
parent.son2 = 'son2';
export default data: { parent: parent };
That way, data.parent
really is a function and the assertion will pass.
Still, I don't think this is a good idea. People have previously asked for support for things like
global: {
weekdays: [ 'Monday', 'Tuesday', ... ]
}
I think we should support non-string translation lookups.
jamesarosen commented
jamesarosen/ember-i18n has been deprecated in favor of ember-intl.