As mentioned in the i18n example https://github.com/nuxt/nuxt.js/blob/master/examples/i18n/middleware/i18n.js
...
const locale = params.lang || 'en'
...
So the lang is in url params like http://xxxx/en/xxxxxx
But I think the lang should be identified from the client browser, not as a param.
So I change this to:
const locale = (window.navigator.language || window.navigator.browserLanguage).toLowerCase() || 'en'
But I got error window is not defiend
, because this code is run in server.
So what should I do to get the lang from user's client? 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/c601">#c601</a>)</em></sub></div>