From d525e751fa52ccbb629246284600d7b69f502f98 Mon Sep 17 00:00:00 2001
From: Mistivia <i@mistivia.com>
Date: Tue, 28 Oct 2025 02:58:20 +0800
Subject: update lang immediately

---
 src/language.js   | 8 +++++---
 src/left_panel.js | 7 ++++++-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/language.js b/src/language.js
index f6dd997..6009c20 100644
--- a/src/language.js
+++ b/src/language.js
@@ -1,12 +1,13 @@
-import { writable, derived } from "svelte/store";
+import { writable, derived, get } from "svelte/store";
 import translations from './translations.js';
+import { leftPanelUpdateLang } from "./left_panel.js";
 
 let defaultLanguage = 'english';
 const userLang = (navigator.language || navigator.userLanguage).toLowerCase();
-if (!userLang.startsWith('zh')) {
+if (userLang.startsWith('zh')) {
     defaultLanguage = 'chinese';
 }
-if (!userLang.startsWith('ja')) {
+if (userLang.startsWith('ja')) {
     defaultLanguage = 'japanese';
 }
 let language = writable(defaultLanguage);
@@ -16,6 +17,7 @@ function setLanguage(newLanguage) {
     localStorage.setItem('language', newLanguage);
     languageState = newLanguage;
     language.set(newLanguage);
+    leftPanelUpdateLang(get(currentTranslations).key);
 }
 
 function initLanguage() {
diff --git a/src/left_panel.js b/src/left_panel.js
index 16f4826..4ca9f46 100644
--- a/src/left_panel.js
+++ b/src/left_panel.js
@@ -34,6 +34,10 @@ function preloadImage(url, callback, errorCallback) {
     img.src = url;
 }
 
+function leftPanelUpdateLang(lang) {
+    let id = get(leftPanelCardId);
+    setLeftPanelCard(id, lang);
+}
 
 function setLeftPanelCard(id, lang) {
     leftPanelCardId.set(id);
@@ -331,5 +335,6 @@ export {
     closeMobileInfo,
     isMobileInfoVisible,
     leftPanelCardImgUrl,
-    leftPanelCardRuby
+    leftPanelCardRuby,
+    leftPanelUpdateLang,
 };
-- 
cgit v1.0

