-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attribute lang
not change
#166
Comments
This is doesn't look like a bug, i think its working as expected.
Reason why you'd want to have a lang attribute at the first place is mainly for SEO. And when the page is loaded for the first time it has the correct lang attribute, thats what matters mostly. I have also built the example on my local and saw that generated pages have the correct lang attribute. |
Yes, everything is correct during the initial load, the issues arise when switching languages. In addition to SEO, translation programs, etc., also consider the But I couldn't figure out how to implement change |
Replace <select on:change="{({ target }) => goto(target.value)}">
{#each $locales as lc}
<option value="/{lc}{route}" selected="{lc === $locale}">{$t(`lang.${lc}`)}</option>
{/each}
</select> With this <select
on:change={({ target }) => {
goto(`/${target.value}${route}`);
document.querySelector("html").setAttribute("lang", target.value);
}}
>
{#each $locales as lc}
<option value={lc} selected={lc === $locale}>{$t(`lang.${lc}`)}</option>
{/each}
</select>
|
Thank you! I am still working with sveltekit-i18n, and I have encountered a few issues. The code I will submit a pull request with this code now. If @jarda-svoboda decides that this is the best way to solve the issue, great. If not, maybe make it better. |
Hello, thanks for the great library
Example Locale-router-static
src/hooks.server.js
If I understand correctly, this code is supposed to change the
lang
attribute when switching languages, but it doesn't work, as evident in the example.<html>
always havelang="en"
.The text was updated successfully, but these errors were encountered: