Skip to content
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

Sveltekit: Update translation outside of component #224

Open
LuMiSxh opened this issue Aug 7, 2023 · 0 comments
Open

Sveltekit: Update translation outside of component #224

LuMiSxh opened this issue Aug 7, 2023 · 0 comments

Comments

@LuMiSxh
Copy link

LuMiSxh commented Aug 7, 2023

Is your feature request related to a problem? Please describe.
A problem I encountered was changing the locale in SvelteKit and only the component the change happnes in updating its translation,

Describe the solution you'd like
In the SvelteKit docs for this library an extra section showing how to update all translations when changing the locale inside a component.

Additional context
I already found a solution for it and have an Idea for implementing it,
Inside the root layout file you just have to wrap your <slot/> inside a svelte key with the $locale as its value.
Everything inside the key-block will re-render once the locale changed.
It would look like so:

<scrip>
    import {locale} from "svelte-i18n";
</script>

{#key $locale}
    <slot/>
{/key}
@LuMiSxh LuMiSxh changed the title Sveltekit: Update transaltion outside of component Sveltekit: Update translation outside of component Aug 7, 2023
pboguslawski added a commit to ibpl/web-certificate-tool that referenced this issue Apr 25, 2024
Fix  problem with some translations unchanged on $locale change.

Related: kaisermann/svelte-i18n#224

Author-Change-Id: IB#1141363
Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant