wegue
wegue copied to clipboard
Refactor VueI18n creation to own module
This refactors the creation of the VueI18n
instance by encapsulating it in an own ES module. So the i18n instance can be imported to other pure ES modules and will allow internationalization there.
This follows the approach given here: https://github.com/kazupon/vue-i18n/issues/149#issuecomment-357455921
This would make the introduction of a global $appLanguage
variable in #356 obsolete by this much cleaner and more versatile approach. If you approve this PR, I'd happily revert #356 afterwards in a separate PR.
Accessing the current app language in pure ES modules could then be done by the following code:
const { i18n } = await import('../../../src/locales/wgu-i18n.js');
console.log(i18n.locale);