Within my app.js
file, I implemented a functionality to enable translation in Vue:
Vue.prototype.trans = string => _.get(window.i18n, string);
This feature works perfectly when used in my Vue files:
{{ trans('translation.name') }}
However, I encountered an issue while working with vuex
and needing to translate some content within a module:
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
export default {
namespaced: true,
state: {
page: 1,
criterias: [
{
name: this.trans('translation.name'),
filter: "life",
active: false
}
}
}
In this context, this.trans('translation.name')
does not function as intended. How can I resolve this issue and make it work as expected?