nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.71k stars 478 forks source link

SEO attributes are not reactive (lang, dir html attribute) with no prefix strategy #2871

Closed jesspinklet closed 5 months ago

jesspinklet commented 6 months ago

Discussed in https://github.com/nuxt-modules/i18n/discussions/2840

Originally posted by **jesspinklet** March 15, 2024 I have this in my app.vue for direction and language. ![image](https://github.com/nuxt-modules/i18n/assets/77070946/8e754891-64d2-4b02-a82a-d001b0104d61) while using strategy **prefix** and changing the locale with `setLocale()` it will be updated as expected. however, with `no prefix` strategy it seems it's not reactive or its not getting updated. is this how it supposed to be? If yes, what's the best way to add a reactive lang and a dir attribute to html?

Reproduction for this issue link

github-actions[bot] commented 6 months ago

Would you be able to provide a reproduction? 🙏

More info ### Why do I need to provide a reproduction? Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making. ### What will happen? If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect. If `needs reproduction` labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it. ### How can I create a reproduction? We have a couple of templates for starting with a minimal reproduction: 👉 [Reproduction starter (v8 and higher)](https://stackblitz.com/fork/github/BobbieGoede/nuxt-i18n-starter/tree/v8) 👉 [Reproduction starter (edge)](https://stackblitz.com/fork/github/BobbieGoede/nuxt-i18n-starter/tree/edge) A public GitHub repository is also perfect. 👌 Please ensure that the reproduction is as **minimal** as possible. See more details [in our guide](https://nuxt.com/docs/community/reporting-bugs/#create-a-minimal-reproduction). You might also find these other articles interesting and/or helpful: - [The Importance of Reproductions](https://antfu.me/posts/why-reproductions-are-required) - [How to Generate a Minimal, Complete, and Verifiable Example](https://stackoverflow.com/help/mcve)
jesspinklet commented 6 months ago

Reproduction for this issue link

BobbieGoede commented 6 months ago

Thanks for the reproduction!

I see your comment in the config file and you're right, this is a bug caused by updating these attributes while only tracking for URL changes. For now I have a workaround for the lang and dir html attributes, I've updated your reproduction here to demonstrate.

Hopefully I'll have a fix ready soon!

meirroth commented 6 months ago

Experiencing the same issue in my project.