I wanted help to change the corresponding link with the language.
Imagine.
I am in the FR language and I am on the page (…/page/terms-et-services), and if I am on the same page and change the language to EN, it doesn’t change to the page (…/page/terms-and-services), it only changes if I go to the footer menu and click on the terms and then it goes to the page (…/page/terms-and-services).
I wanted, for example, if it was in the FR language with the link (/page/terms-et-services) and changed the language to EN it would go to the page (/page/terms-of-service), but this would only happen if the user was on the link (/page)
In the footer menu I use it this way.
<li v-if="legal.visibility" v-for="(legal, index) in config.legal.filter(legal => legal.lang === getLocale())" :key="index">
<router-link :to="{name: 'DynamicPage', params: {slug: legal.slug }}" class="hover-text-theme">
{{ legal.title }}
</router-link>
</li>
And I user in the languagepage
export default {
name: 'LanguageSwitcher',
components: { CountryFlag, ChevronDownIcon },
data() {
return {
language: this.$store.getters.currentLanguage,
isOpen: false,
}
},
computed: {
selected: function () {
return this.$store.getters.languages.find(language => language.code === this.language);
},
},
beforeMount() {
if (! this.selected) {
this.language = this.$store.getters.languages[0].code;
}
},
watch: {
locale() {
this.$router.replace({ params: { lang: this.language } }).catch(() => {})
}
},
methods: {
changeLanguage(language) {
// Emit selected
this.$emit('input', language.value)
// Get selected
this.language = language.code
// Close menu
this.isOpen = false
this.$store.dispatch('setLanguage', language.code);
setTimeout(() => location.reload(), 10)
},
toggleSwitch() {
this.isOpen = !this.isOpen
},
hideSwitch() {
this.isOpen = false
},
},
}
I use these 5 links - Terms of Service | Privacy | Cookie | Policy | About Us
Thank you