Skip to content

Commit

Permalink
utilize navigate
Browse files Browse the repository at this point in the history
  • Loading branch information
ulfgebhardt committed Mar 27, 2024
1 parent 0e370c2 commit 6887bec
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions presenter/src/components/language/LanguageSelector.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<v-select
v-model="selectedLocale"
v-model="$i18n.locale"
density="compact"
name="language"
:items="languages"
Expand Down Expand Up @@ -28,6 +28,7 @@
</template>

<script lang="ts" setup>
import { navigate } from 'vike/client/router'
import { ref } from 'vue'
import { usePageContext } from '#context/usePageContext'
Expand All @@ -37,15 +38,15 @@ import { localizedLocale } from '#src/locales'
const pageContext = usePageContext()
const languages = ref(localizedLocale)
const selectedLocale = ref(i18n.global.locale.value)
const updateLanguage = () => {
const { locale, urlOriginal } = pageContext
window.location.href = urlOriginal
// eslint-disable-next-line security/detect-non-literal-regexp
.replace(new RegExp(`/(${locale})?(.*)`, 'g'), `/${selectedLocale.value}/$2`)
.replace(/(\/(#|\?))?/g, '$2')
navigate(
urlOriginal
// eslint-disable-next-line security/detect-non-literal-regexp
.replace(new RegExp(`/(${locale})?(.*)`, 'g'), `/${i18n.global.locale.value}/$2`)
.replace(/(\/(#|\?))?/g, '$2'),
)
}
</script>

Expand Down

0 comments on commit 6887bec

Please sign in to comment.