fix(docs): complete language switching - update sidebar and hero instantly
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 <noreply@anthropic.com>
This commit is contained in:
parent
7549ee43a6
commit
4c5e88f322
1 changed files with 13 additions and 4 deletions
|
|
@ -232,13 +232,22 @@ function updateURL(slug, lang) {
|
||||||
|
|
||||||
// Listen for language changes from i18n system
|
// Listen for language changes from i18n system
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
window.addEventListener('languageChanged', (e) => {
|
window.addEventListener('languageChanged', async (e) => {
|
||||||
const newLang = e.detail.language;
|
const newLang = e.detail.language;
|
||||||
currentLanguage = newLang;
|
currentLanguage = newLang;
|
||||||
|
|
||||||
// Reload current document in new language
|
// Update page UI (hero section, sidebar headings, etc.)
|
||||||
if (currentDocument) {
|
updatePageUI(newLang);
|
||||||
loadDocument(currentDocument.slug, 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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue