Skip to content

Commit

Permalink
simplify things
Browse files Browse the repository at this point in the history
  • Loading branch information
ulfgebhardt committed Mar 26, 2024
1 parent 76ecd1f commit bbc0b8a
Showing 1 changed file with 7 additions and 26 deletions.
33 changes: 7 additions & 26 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 @@ -32,36 +32,17 @@ import { ref } from 'vue'
import { usePageContext } from '#context/usePageContext'
import i18n from '#plugins/i18n'
import { LocaleCode, locales, localizedLocale } from '#src/locales'
import { localizedLocale } from '#src/locales'
const pageContext = usePageContext()
const languages = ref(localizedLocale)
const selectedLocale = ref(i18n.global.locale.value)
const updateLanguage = () => {
if (locales.includes(selectedLocale.value)) {
i18n.global.locale.value = selectedLocale.value
}
let { urlOriginal } = pageContext
const urlPaths = urlOriginal.split('/')
let urlWithoutLocale = ''
let leadingSlash = '/'
if (urlPaths[1].indexOf('#') > -1) {
const hashUrl = urlPaths[1].split('#')
urlWithoutLocale = '#' + hashUrl[1]
leadingSlash = ''
} else if (!locales.includes(urlPaths[1] as LocaleCode)) {
urlWithoutLocale = leadingSlash + urlPaths[1]
}
if (locales.includes(selectedLocale.value)) {
urlWithoutLocale += leadingSlash + urlPaths.slice(2).join('/')
urlOriginal = '/' + selectedLocale.value + urlWithoutLocale
}
window.location.href = urlOriginal
const { locale } = pageContext
window.location.href = window.location.href.replace(
`/${locale}/`,
`/${i18n.global.locale.value}/`,
)
}
</script>

Expand Down

0 comments on commit bbc0b8a

Please sign in to comment.