Closed awilczek closed 9 years ago
What would be the interest of this ? Extending a language for a specific regional language ?
You may do it by reading the files and extend the objects and passing an object on locales
option.
Could you make a pull request ?
In our project - we would use this kind of feature for overriding the language by country-specific translations. But your example could be covered as well. And yes, we came to the solution you propose:
var locales = _.reduce(["de-de", "at-de"], function(result, locale) {
var base = _.clone(require('../locales/' + locale.slice(-2)));
result[locale] = _.merge(base, require('../locales/' + locale));
return result;
}, {});
i18n.expressBind(app, {
locales: locales,
defaultLocale: "de-de"
});
But it would be nice to do it in just one config parameter. I'll prepare a PR in couple of weeks.
It would be nice to have a feature like inheritance between dictionaries that could spare a lot of duplications. Assuming we have files de-de.json and at-de.json - both extending the root de.json - we would provide the options:
Where
parents
is a regexp for extracting parent name for each file. What do you think?