File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -625,7 +625,7 @@ function ThePage({
625625 book : data ?. book ,
626626 chapter : data ?. chapter ,
627627 } ) ;
628- os . syncConfigBotTagsToURL ( [ "book" , "chapter" , "translation" ] ) ;
628+ os . syncConfigBotTagsToURL ( [ "book" , "chapter" , "translation" , "lang" ] ) ;
629629 }
630630 } , [ data ] ) ;
631631
Original file line number Diff line number Diff line change @@ -153,9 +153,13 @@ export async function initI18n(): Promise<any> {
153153 throw new Error ( "i18next failed to load from CDN" ) ;
154154 }
155155
156- // Get saved language from localStorage, or detect from browser using navigator.language
156+ // Check configBot.tags.lang first, then localStorage, then browser detection
157+ const tagLang = configBot ?. tags ?. lang ;
157158 const savedLang = localStorage . getItem ( "i18nextLng" ) ;
158- const detectedLang = savedLang || getBrowserLanguage ( ) ;
159+ const detectedLang =
160+ ( tagLang && supportedLangCodes . includes ( tagLang ) ? tagLang : null ) ||
161+ savedLang ||
162+ getBrowserLanguage ( ) ;
159163
160164 await i18next . init ( {
161165 resources,
@@ -200,6 +204,10 @@ export function t(key: string, options?: any): string {
200204export function changeLanguage ( lng : string ) : Promise < void > {
201205 if ( i18nInstance ) {
202206 localStorage . setItem ( "i18nextLng" , lng ) ;
207+ // Sync to configBot tags
208+ if ( configBot ?. tags ) {
209+ configBot . tags . lang = lng ;
210+ }
203211 // Update document direction for RTL languages
204212 const langConfig = availableLanguages . find ( ( l ) => l . code === lng ) ;
205213 document . documentElement . dir = langConfig ?. rtl ? "rtl" : "ltr" ;
You can’t perform that action at this time.
0 commit comments