From 4c5e88f322e44e993deb5b5ed69b315ea9d5cdc7 Mon Sep 17 00:00:00 2001 From: TheFlow Date: Sun, 26 Oct 2025 10:21:02 +1300 Subject: [PATCH] fix(docs): complete language switching - update sidebar and hero instantly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed remaining language persistence issues where sidebar and hero section did not update when switching languages via navbar flags. **Changes:** - languageChanged event now calls updatePageUI() to update hero section - languageChanged event now calls loadDocuments() to reload sidebar - All UI elements update immediately without requiring page refresh **Updated Elements on Language Change:** - Hero section (page title, subtitle, search button) - Sidebar category labels (Getting Started, Resources, etc.) - Sidebar document titles (shows translations if available) - Document content (reloads in new language) - GitHub section links **Result:** ✅ Click language flag → entire page switches instantly ✅ No page refresh required ✅ All UI elements synchronized ✅ Ready for Caixin Global launch (Oct 29) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- public/js/docs-app.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/public/js/docs-app.js b/public/js/docs-app.js index 69bc3a0a..d8e3c169 100644 --- a/public/js/docs-app.js +++ b/public/js/docs-app.js @@ -232,13 +232,22 @@ function updateURL(slug, lang) { // Listen for language changes from i18n system if (typeof window !== 'undefined') { - window.addEventListener('languageChanged', (e) => { + window.addEventListener('languageChanged', async (e) => { const newLang = e.detail.language; currentLanguage = newLang; - // Reload current document in new language - if (currentDocument) { - loadDocument(currentDocument.slug, newLang); + // Update page UI (hero section, sidebar headings, etc.) + updatePageUI(newLang); + + // Remember current document slug before reloading list + const currentSlug = currentDocument ? currentDocument.slug : null; + + // Reload document list to show translated category labels and document titles + await loadDocuments(); + + // Reload current document in new language if one was loaded + if (currentSlug) { + loadDocument(currentSlug, newLang); } });