-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Hi,
Is it possible to use the plugin for storing localization information and translations multiple times? What I mean by this, is I would like to have a way to implement an application wide language, and a language that is independent of the app - for example a document language.
I am currently building an application where users would for example log in with the language set to German, but when they create a pdf document for example, with one of the tools in the app, they should have the possiblity of setting/toggling the translation of the document between German and English. This should not effect the application language though, which happens when I change the locale with Vue.i18n.set(newLocale).
I thought it would be possible to simply use the plugin twice, as follows:
Vue.use(
vuexI18n.plugin,
store,
{
// Will use fallback translation, default translation or key
onTranslationNotFound(locale, key) {
logger.warn(`i18n :: Key '${key}' not found for locale '${locale}'`);
if (locale === 'en-GB') {
throw new TraslationError(key, locale);
}
},
},
);
Vue.use(
vuexI18n.plugin,
store,
{
moduleName: 'documentTranslations',
// Will use fallback translation, default translation or key
onTranslationNotFound(locale, key) {
logger.warn(`documentTranslations :: Key '${key}' not found for locale '${locale}'`);
if (locale === 'en-GB') {
throw new TraslationError(key, locale);
}
},
},
);
which I thought would register the internationalize plugin on the vue instance, and will generate helper functions in my Store - once for the default i18n module name and then documentTranslations for the second module name. This however, doesn't seem to work, and will always only work for the first one (I only see the i18n module in my store).
Am I missing something or misunderstanding the way this works? Is what I am trying to achieve possible?