From http://requirejs.org/docs/api.html#i18n I found how to set the current locale, which is:
requirejs.config({
config: {
i18n: {
locale: 'fr-fr'
}
}
});
But then, how can I read configuration inside some module to see the value of the current locale?
It's been a few months so I'm guessing you've already figured this out (or found a workaround), but I'll answer the question for the sake of future users who might stumble across this page. Inside any require module, you can always access the "require" and "reuirejs" globals. So, inside your module, you can do this:
//Module defition
define(function (['abcd', 'efgh'], abcd, efgh) {
//Note: if you gave your context a name in the config, then replace "_" with that name
var globalConfigs = requirejs.s.contexts._.config;
console.log(globalConfigs.i18n.locale); // > fr-fr
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With