Nuxt.js: How can I use the translate service by vue-i18n in store module actions?

Created on 25 Oct 2017  路  3Comments  路  Source: nuxt/nuxt.js

Something like this:

actions: {
  nextStage ({ state, commit, dispatch }, params) {
    const text = vue.$t('message.chat.name-message-1')
  }
}

This question is available on Nuxt.js community (#c1744)

Most helpful comment

This still doesn't seem to be resolved. I can't find a way to, for example, show toast notifications:

// inside Vuex action. doesn't work. (....t is not a function)
this.$toast.error(Vue.t('error.locked'))

All 3 comments

I think store is better to contain keys like message.chat.name-message-1 and use this.$t(...) in component to compute the real values.

More info you can refer here 馃樃 .

This still doesn't seem to be resolved. I can't find a way to, for example, show toast notifications:

// inside Vuex action. doesn't work. (....t is not a function)
this.$toast.error(Vue.t('error.locked'))

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VincentLoy picture VincentLoy  路  3Comments

maicong picture maicong  路  3Comments

pehbehbeh picture pehbehbeh  路  3Comments

vadimsg picture vadimsg  路  3Comments

mattdharmon picture mattdharmon  路  3Comments