Skip to content

Commit 7d27921

Browse files
Merge pull request #169 from alkorlos/add-example-locale-router-static-change-lang
Add example locale router static change lang
2 parents eb20538 + 4c04d36 commit 7d27921

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

examples/locale-router-static/src/routes/[lang]/+layout.svelte

+7-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@
2222
<br />
2323
<br />
2424
<br />
25-
<select on:change="{({ target }) => goto(target.value)}">
25+
<select
26+
on:change={({ target }) => {
27+
goto(`/${target.value}${route}`);
28+
document.querySelector('html').setAttribute('lang', target.value);
29+
}}
30+
>
2631
{#each $locales as lc}
27-
<option value="/{lc}{route}" selected="{lc === $locale}">{$t(`lang.${lc}`)}</option>
32+
<option value={lc} selected={lc === $locale}>{$t(`lang.${lc}`)}</option>
2833
{/each}
2934
</select>

0 commit comments

Comments
 (0)