3👍
✅
First a question. Why doing translations in mutations file? I’d keep translations in your components only.
You can however achieve what you want, by doing so
// i18n.js
const i18n = new VueI18n();
export default i18n;
// main.js
import VueI18n from 'vue-i18n';
import i18n from './i18n.js';
Vue.use(VueI18n);
new Vue({
i18n,
...
});
// Anywhere else, grab the i18n instance to do translations
import i18n from './i18n.js';
i18n.t('translate this');
Documentation on all the methods available on the VueI18n instance.
Source:stackexchange.com