Skip to content

Commit

Permalink
fix: switching languages when writing a post clears all content (#556)
Browse files Browse the repository at this point in the history
* Fix 552: check if language changes before invalidating

* Fix 551: by subscribing to onSetLanguageTag
  • Loading branch information
RufusKoggRojder authored Nov 9, 2024
1 parent 5c4f2af commit d817ae4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/routes/LanguageSwitcher.svelte
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<script lang="ts">
import { languageTag } from "$paraglide/runtime";
import { languageTag, onSetLanguageTag } from "$paraglide/runtime";
import { page } from "$app/stores";
import { i18n } from "$lib/utils/i18n";
import { invalidateAll } from "$app/navigation";
import { twMerge } from "tailwind-merge";
let clazz = "";
export { clazz as class };
onSetLanguageTag(() => {
invalidateAll();
});
</script>

<a
class={twMerge("btn btn-ghost", clazz)}
href={i18n.route($page.url.pathname)}
hreflang={languageTag() === "sv" ? "en" : "sv"}
on:click={() => invalidateAll()}
>
<slot>
{languageTag() === "sv" ? "EN" : "SV"}
Expand Down

0 comments on commit d817ae4

Please sign in to comment.