Just starting out with Vue.js and looking to implement Vue I18n. However, I'm facing an issue setting the locale on Vue I18n and also setting the HTML lang attribute to the same locale. The challenge is that I can't access the document object in Server Side Rendered (SSR) mode. So, how can I modify the Server Side Rendered HTML before Client Side rendering?
if (process.env.CLIENT) // This does not seem good hydration.
document.querySelector('html').setAttribute('lang', i18n.global.locale.value)
I attempted to address the issue using the Meta plugin, but the lang attribute remains 'en-US'.
useMeta(() => ({
htmlAttr: {
lang: i18n.global.locale.value
}
}))
Opting not to utilize the Quasar Language Pack due to limitations on region codes, I made the decision to configure the Quasar Lang settings with no html attrs set to true
:
// quasar.config.js
framework: {
config: {
lang: {
noHtmlAttrs: true // add this
}
},
Despite this change, the lang attribute still disappears from the HTML tag.