File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import { onBeforeMount } from 'vue'
1919
2020onBeforeMount (() => {
2121 if (typeof window !== ' undefined' ) {
22- localStorage .setItem (' docs-lang-preference' , ' / en/' )
22+ localStorage .setItem (' docs-lang-preference' , ` ${ import .meta.env.BASE_URL} en/` )
2323 }
2424})
2525</script>
Original file line number Diff line number Diff line change @@ -20,18 +20,19 @@ import { onBeforeMount } from 'vue'
2020onBeforeMount (() => {
2121 if (typeof window === ' undefined' ) return
2222
23+ const base = import .meta.env.BASE_URL
2324 const userLang = navigator .language || navigator .userLanguage || ' '
2425 const savedLang = localStorage .getItem (' docs-lang-preference' )
2526
2627 // Use saved preference if exists, otherwise use browser language
27- const targetLang = savedLang || (userLang .startsWith (' zh' ) ? ' / zh/' : ' / en/' )
28+ const targetLang = savedLang || (userLang .startsWith (' zh' ) ? ` ${ base } zh/` : ` ${ base } en/` )
2829 const currentPath = window .location .pathname
2930
3031 // Only redirect if not already on correct language path
31- if (targetLang === ' /zh/' && ! currentPath .startsWith (' /zh' )) {
32- window .location .replace (' / zh/' )
33- } else if (targetLang === ' /en/' && ! currentPath .startsWith (' /en' )) {
34- window .location .replace (' / en/' )
32+ if (targetLang . endsWith ( ' /zh/' ) && ! currentPath .includes (' /zh/ ' )) {
33+ window .location .replace (` ${ base } zh/` )
34+ } else if (targetLang . endsWith ( ' /en/' ) && ! currentPath .includes (' /en/ ' )) {
35+ window .location .replace (` ${ base } en/` )
3536 }
3637})
3738</script >
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import { onBeforeMount } from 'vue'
1919
2020onBeforeMount (() => {
2121 if (typeof window !== ' undefined' ) {
22- localStorage .setItem (' docs-lang-preference' , ' / zh/' )
22+ localStorage .setItem (' docs-lang-preference' , ` ${ import .meta.env.BASE_URL} zh/` )
2323 }
2424})
2525</script>
You can’t perform that action at this time.
0 commit comments