vue-gettext: Cant set a language per request with server side rendering (SSR).

Hello again! And thank you for your work. I’ve began porting our application to SSR and am finding that vue-gettext uses a global setting for all vue instances for the current language (i.e. Vue.config.language). This is a problem for server side rendering because a different language per request may be required. One request could set the global language value which would clobber the language context for other request.

There is a nuxt.js example of how they recommend to handle i18n https://nuxtjs.org/guide/plugins/#inject-in-root-amp-context. Notice how the plugin is being intergrated. They first call a Vue.use to wire up the properties and methods that a component will need and then per request setup the language on the app root component. Then the language can be accessed in components via this.$root.language.

This I think would actually simplify the codebase quite a bit as well as you wont have to instantiate a languageMixinVm. You just explain in the “How to Use” that in the the root component they need to define a “language” property (by default “language” would be the property but should be customizable). It could be computed or just plain data.

@kemar I’d love to hear your thoughts on this.

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

@trainiac personally I use cookies for translations with SSR. Pull value from cookies -> set the global $language param on the Node side