i18n-webpack-plugin
i18n-webpack-plugin copied to clipboard
Support adding nested values in JSON
Let say the json file look like
{
"albums": {
"sub_menu": {
"all": "All Albums",
"recent": "Recent",
}
}
}
In this case i want to use the recent
keyword such as __('albums.sub_menu.recent')
for now when using like this it is printing [object object]
It would be great feature :)
This would be ideal
I wrote it by myself but there already exists such a version
function byString(object, stringKey) { stringKey = stringKey.replace(/^./, ''); // strip a leading dot
var keysArray = stringKey.split('.');
for (var i = 0, length = keysArray.length; i < length; ++i) {
var key = keysArray[i];
if (key in object) {
object = object[key];
} else {
return;
}
}
return object;
}
you can use this soulution
Thanks @IvanProdaiko94. On closer inspection it looks as if this code is in the repo (fixed in #9), but not the version on npm (as pointed out in #17). Could do with releasing a new version!
Hello, just for the record and for all other people looking for the same answer. The feature is already there by adding "nested" property into plugin config. It's not documented yet. This issue can be closed I guess :)
I think this issue can be closed, no?