From 0d836a5c384361448c546c9e55c03d76e38a5f72 Mon Sep 17 00:00:00 2001
From: Mistivia <i@mistivia.com>
Date: Thu, 2 Oct 2025 00:12:55 +0800
Subject: show card name in japanese and english

---
 README.md                         |  6 ++++--
 data/build-card-info.py           | 28 ++++++++++++++++++++++++++++
 src/components/right_panel.svelte |  2 +-
 src/search.js                     |  6 +++++-
 src/translations.js               |  3 +++
 5 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 3d17143..c5c9e99 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,11 @@
 
 游戏王卡组编辑器
 
-演示：[raye.mistivia.com/ygodeck](https://raye.mistivia.com/ygodeck/#o6lXBaOpVwWjqVcFg0dLBfn5ewBwUKcCUuc5BI2UeADUmP0BrvTMAjkebAKufHMEXWh5BeFWRAJwhCsDvadvAUpwSQMS2aACgJaYAJSWmACKlpgAGXcGAHNnwQVgUk0Bhz2DA6G7BgUIMTwBgYVnAzKRLQQBS+AFKWGQA62pWwAuye8Bl3MqBKtuXAWYhMIEEtFCBdCWmADalpgA3+4aBd2y4wE=!0iNuAeEF3wXuZyIC6+mlA4uXFwDUD4MBHFb0BHebkwI=!)
+遊戯王デッキビルダー
 
-## 截图
+Demo：[raye.mistivia.com/ygodeck](https://raye.mistivia.com/ygodeck/#o6lXBaOpVwWjqVcFg0dLBfn5ewBwUKcCUuc5BI2UeADUmP0BrvTMAjkebAKufHMEXWh5BeFWRAJwhCsDvadvAUpwSQMS2aACgJaYAJSWmACKlpgAGXcGAHNnwQVgUk0Bhz2DA6G7BgUIMTwBgYVnAzKRLQQBS+AFKWGQA62pWwAuye8Bl3MqBKtuXAWYhMIEEtFCBdCWmADalpgA3+4aBd2y4wE=!0iNuAeEF3wXuZyIC6+mlA4uXFwDUD4MBHFb0BHebkwI=!)
+
+## Screenshot
 
 ![image](https://oss.nebula.moe/shared-files/2025/03/13/e758a78eab/ygodeckbuilder-screenshot.png)
 
diff --git a/data/build-card-info.py b/data/build-card-info.py
index 38f7b55..f361265 100644
--- a/data/build-card-info.py
+++ b/data/build-card-info.py
@@ -11,10 +11,38 @@ outData = dict()
 def convert(card):
     newCard = dict()
     newCard['names'] = []
+    cnidx = -1
+    jpidx = -1
+    enidx = -1
+    i = 0
     for namek in ['cn_name', 'sc_name', 'md_name', 'nwbbs_n', \
                   'cnocg_n', 'jp_ruby', 'jp_name', 'en_name', 'set_ext']:
         if namek in card and len(card[namek]) > 0:
             newCard['names'].append(card[namek])
+            if namek == 'cn_name':
+                cnidx = i
+            if namek == 'en_name':
+                enidx = i
+            if namek == 'jp_name':
+                jpidx = i
+            i += 1
+    newCard['en'] = 0
+    newCard['cn'] = 0
+    newCard['jp'] = 0
+
+    if cnidx >= 0:
+        newCard['cn'] = cnidx
+
+    if enidx >= 0:
+        newCard['en'] = enidx
+    elif jpidx >= 0:
+        newCard['en'] = card['jp_name']
+    
+    if jpidx >= 0:
+        newCard['jp'] = jpidx
+    elif enidx >= 0:
+        newCard['jp'] = enidx
+
     newCard['isExtra'] = False
     for t in ['超量', '连接', '同调', '融合']:
         if t in card['text']['types']:
diff --git a/src/components/right_panel.svelte b/src/components/right_panel.svelte
index 28f4307..2e933d0 100644
--- a/src/components/right_panel.svelte
+++ b/src/components/right_panel.svelte
@@ -28,7 +28,7 @@
                    <div class="card-thumbnail">
                        <CardThumb id={card.id} idx={-1} area="search" limitNum={cornerMark(card.id, $format)} />
                    </div>
-                   <span>{card.name}</span>
+                   <span>{card.names[card[$currentTranslations.key]]}</span>
                </div>
            {/each}
     </div>
diff --git a/src/search.js b/src/search.js
index f1f7dbd..a4355a0 100644
--- a/src/search.js
+++ b/src/search.js
@@ -39,7 +39,11 @@ function doSearch(ver, query) {
             }
         }
         if (hit) {
-            result.push({"id": key, "name": cardDb[key].names[0]})
+            let c = {"id": key, "names": cardDb[key].names};
+            c['cn'] = cardDb[key].cn;
+            c['jp'] = cardDb[key].jp;
+            c['en'] = cardDb[key].en;
+            result.push(c);
         }
     }
     if (ver !== curVer) return;
diff --git a/src/translations.js b/src/translations.js
index af430cb..08d6edf 100644
--- a/src/translations.js
+++ b/src/translations.js
@@ -1,5 +1,6 @@
 const translations = {
     chinese: {
+        key: "cn",
         // Buttons
         open: "打开",
         save: "保存",
@@ -41,6 +42,7 @@ const translations = {
         loading: "加载中..."
     },
     english: {
+        key: "en",
         // Buttons
         open: "Open",
         save: "Save",
@@ -82,6 +84,7 @@ const translations = {
         loading: "Loading..."
     },
     japanese: {
+        key: "jp",
         // Buttons
         open: "開く",
         save: "保存",
-- 
cgit v1.0

