Home

Issue: 1156

Async messages for i18n

[issue link]
"nuxt": "^1.0.0-alpha.5",
"vue-i18n": "^7.0.5"

Hi there,

I’ve got difficulties to fill the i18n messages property from a remote file (collaborative translation).

In other words, can I set/modify a plugin after an async operation and before the rendering?

For now, I feed the store using the nuxtServerInit action then I instanciate it this way:

// ~/plugins/i18n.js

import Vue from 'vue'
import VueI18n from 'vue-i18n'

Vue.use(VueI18n)

export default ({ app, store }) => {
  // Set i18n instance on app
  app.i18n = new VueI18n({
    locale: store.state.locale,
    fallbackLocale: store.state.fallbackLocale,
    messages: store.state.messages
  })
}

But the problem is the store is empty when the server render my page (still fetching) so I got a [vue-i18n] Cannot translate the value of keypath 'hello'. Use the value of keypath as default. warning message and the template updates 1 second after.

Any ideas?

Thanks

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