-
Hello, I'm new to Problem:If I dynamically swap languages I get "stale" content when switching routes -- as-in the pages don't re-render for the new language. I think this is because If I:
Background:I'm using vue-router with unplugin-vue-router to create simple routes. I have fairly simple pages:
<script setup lang="ts">
import { useFluent } from "fluent-vue";
import { swapLocale, useLocale } from "@/fluent";
const { $t } = useFluent();
const { currentLocale, nextLocale } = useLocale();
</script>
<template>
<h1>{{ $t("title") }} ({{ currentLocale }}</h1>
<p>
{{ $t("description") }}
</p>
<router-link to="/other">
<button>{{ $t("nav-other") }}</button>
</router-link>
<button @click="swapLocale">Set lang={{ nextLocale }}</button>
</template>
<script setup lang="ts">
import { useFluent } from "fluent-vue";
import { swapLocale, useLocale } from "@/fluent";
const { $t } = useFluent();
const { currentLocale, nextLocale } = useLocale();
</script>
<template>
<h1>{{ $t("title") }} ({{ currentLocale }}</h1>
<p>
{{ $t("description") }}
</p>
<router-link to="/">
<button>{{ $t("nav-root") }}</button>
</router-link>
<button @click="swapLocale">Set lang={{ nextLocale }}</button>
</template> The only difference is the What's telling for me is that Am I doing something really wrong here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
Can you share contents of |
Beta Was this translation helpful? Give feedback.
Found the solution, but not the cause. 🙂
If you remove
const { $t } = useFluent();
from components, it should start working.