kaisermann / svelte-i18n

Internationalization library for Svelte
MIT License
1.22k stars 79 forks source link

Locale not set correctly on some page loads #250

Open alkorlos opened 2 months ago

alkorlos commented 2 months ago

Thank you for the great library!

Describe the bug Find this issue due to the incorrect value of the lang attribute. svelte-i18n automatically changes the value of the lang attribute on the <html> element. Most of the time, it works correctly. However, on some page loads, the lang attribute gets an incorrect value.

Logs No errors or warnings.

To Reproduce svelte-i18n-issue-lang In reproduce only SvelteKit is initialized, and the svelte-i18n library is added. In this case, the bug appears rarely, but it does appear. Attaching a video 2024-07-04 19-52-07.webm, bug on 8 sec. When loading the page at the address /de, the lang attribute is must set to de, but once it is set to en.

As mentioned, in the demo above, this bug appears rarely. Encountered it in a project where this error occurs more frequently, can provide a link to the project if needed, it's not commercial code.

When preparing the example, noticed a problem with content localization, not just with the lang attribute. In the project where discovered this issue, only the lang attribute works incorrectly, the content localization is displayed without errors.

Expected behavior Locale set correctly on all page loads.

Information about your project:

Additional context Add any other context about the problem here.

aiwaki commented 1 month ago

Same