@@ -127,25 +127,24 @@ const MobileLanguagePicker = () => {
127
127
let currentPath = location . pathname ;
128
128
129
129
// Handle docs paths
130
- if ( currentPath . startsWith ( '/docs/' ) ) {
131
- // Remove existing locale from docs path
132
- let cleanPath = currentPath . replace ( / ^ \/ d o c s \/ ( j p | j a | r u | z h | z h - C N ) (? = \/ | $ ) / , '/docs' ) ;
133
-
134
- // If no locale was removed, we're already on a clean path
135
- if ( cleanPath === currentPath ) {
136
- cleanPath = currentPath ;
137
- }
138
-
139
- // Build new URL with target locale
140
- if ( locale === i18n . defaultLocale || locale === 'en' ) {
141
- // English: keep clean path as-is
142
- href = cleanPath ;
143
- } else {
144
- // Other languages: inject locale after /docs
145
- if ( cleanPath === '/docs' || cleanPath === '/docs/' ) {
130
+ if ( currentPath . startsWith ( '/docs' ) ) {
131
+ // Handle docs root paths specifically
132
+ if ( currentPath === '/docs' || currentPath === '/docs/' ) {
133
+ if ( locale === i18n . defaultLocale || locale === 'en' ) {
134
+ href = '/docs/' ;
135
+ } else {
146
136
href = `/docs/${ locale } /` ;
137
+ }
138
+ } else {
139
+ // Remove existing locale from docs path if present
140
+ let cleanPath = currentPath . replace ( / ^ \/ d o c s \/ ( j p | j a | r u | z h | z h - C N ) (? = \/ | $ ) / , '/docs' ) ;
141
+
142
+ // Build new URL with target locale
143
+ if ( locale === i18n . defaultLocale || locale === 'en' ) {
144
+ href = cleanPath ;
147
145
} else {
148
- href = cleanPath . replace ( '/docs/' , `/docs/${ locale } /` ) ;
146
+ // For non-English locales, inject locale after /docs
147
+ href = cleanPath . replace ( '/docs' , `/docs/${ locale } ` ) ;
149
148
}
150
149
}
151
150
} else {
0 commit comments