Static GitHub Issues

[1156] Async messages for i18n

prev: Check logged user in firebase with middleware
next: Get store in an external js file.
"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

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1017">#c1017</a>)</em></sub></div>