From f96aba847113fa752854279d20874b480f40565f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Sep 2025 06:54:34 +0000 Subject: [PATCH 1/2] Initial plan From 901bcab75f18a822ca668fa67bcc5981142f195c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Sep 2025 07:04:19 +0000 Subject: [PATCH 2/2] Implement i18n translation for all UI text Co-authored-by: thekingofcity <3353040+thekingofcity@users.noreply.github.com> --- src/components/signs.tsx | 104 +++++++++++++++-------------- src/components/window-header.tsx | 2 +- src/i18n/translations/en.json | 21 ++++-- src/i18n/translations/ja.json | 17 ++++- src/i18n/translations/ko.json | 17 ++++- src/i18n/translations/zh-Hans.json | 23 +++++-- src/i18n/translations/zh-Hant.json | 21 ++++-- 7 files changed, 133 insertions(+), 72 deletions(-) diff --git a/src/components/signs.tsx b/src/components/signs.tsx index e58e4162..ab6f6718 100644 --- a/src/components/signs.tsx +++ b/src/components/signs.tsx @@ -1,5 +1,6 @@ /* eslint-disable no-case-declarations */ import React, { useState, useRef } from 'react'; +import { useTranslation } from 'react-i18next'; // 在 signs.tsx 顶部添加 import './MetroSignGenerator.css'; @@ -36,6 +37,7 @@ const getBlockWidth = (style: string): number => { }; const RailSignGenerator: React.FC = () => { + const { t } = useTranslation(); const [blocks, setBlocks] = useState([ { id: 1, style: 'Exit', cutLine: false, specialStyles: {}, collapsed: false }, ]); @@ -47,50 +49,50 @@ const RailSignGenerator: React.FC = () => { Exit: [ { type: 'radio', - label: '对齐方式', + label: t('blocks.styles.specials.text_align'), defaultValue: 'C', options: [ - { value: 'R', label: '靠右对齐' }, - { value: 'L', label: '靠左对齐' }, - { value: 'C', label: '居中对齐' }, + { value: 'R', label: t('blocks.styles.specials.align_right') }, + { value: 'L', label: t('blocks.styles.specials.align_left') }, + { value: 'C', label: t('blocks.styles.specials.align_center') }, ], }, ], Line: [ - { type: 'number', label: '线路编号', defaultValue: '10' }, - { type: 'text', label: '线路颜色', defaultValue: '#00a3c2' }, + { type: 'number', label: t('blocks.styles.specials.line_number'), defaultValue: '10' }, + { type: 'text', label: t('blocks.styles.specials.line_color'), defaultValue: '#00a3c2' }, ], 'Line-space': [ - { type: 'number', label: '线路编号', defaultValue: '10' }, - { type: 'text', label: '线路颜色', defaultValue: '#00a3c2' }, + { type: 'number', label: t('blocks.styles.specials.line_number'), defaultValue: '10' }, + { type: 'text', label: t('blocks.styles.specials.line_color'), defaultValue: '#00a3c2' }, ], ExitText: [ - { type: 'text', label: '出口编号', defaultValue: 'A', maxLength: 1 }, - { type: 'text', label: '出口下角标', defaultValue: '', maxLength: 1 }, - { type: 'text', label: '出口中文', defaultValue: '蓝靛厂南路' }, - { type: 'text', label: '出口英文', defaultValue: 'Landianchang South Rd.' }, + { type: 'text', label: t('blocks.styles.specials.exit_letter'), defaultValue: 'A', maxLength: 1 }, + { type: 'text', label: t('blocks.styles.specials.exit_lower'), defaultValue: '', maxLength: 1 }, + { type: 'text', label: t('blocks.styles.specials.exit_zh'), defaultValue: '蓝靛厂南路' }, + { type: 'text', label: t('blocks.styles.specials.exit_en'), defaultValue: 'Landianchang South Rd.' }, ], To: [ - { type: 'text', label: '终点站中文', defaultValue: '宛平城' }, - { type: 'text', label: '终点站英文', defaultValue: 'Wanpingcheng' }, + { type: 'text', label: t('blocks.styles.specials.terminal_zh'), defaultValue: '宛平城' }, + { type: 'text', label: t('blocks.styles.specials.terminal_en'), defaultValue: 'Wanpingcheng' }, { type: 'radio', - label: '对齐方式', + label: t('blocks.styles.specials.text_align'), defaultValue: 'R', options: [ - { value: 'R', label: '靠右对齐' }, - { value: 'L', label: '靠左对齐' }, - { value: 'C', label: '居中对齐' }, // 添加居中对齐选项 + { value: 'R', label: t('blocks.styles.specials.align_right') }, + { value: 'L', label: t('blocks.styles.specials.align_left') }, + { value: 'C', label: t('blocks.styles.specials.align_center') }, // 添加居中对齐选项 ], }, { type: 'radio', - label: '线路类型', + label: t('blocks.styles.specials.line_type'), defaultValue: 'NM', options: [ - { value: 'NM', label: '普通线' }, - { value: 'LOOP', label: '环线' }, - { value: 'T', label: '终点站' }, + { value: 'NM', label: t('blocks.styles.specials.normal_line') }, + { value: 'LOOP', label: t('blocks.styles.specials.loop_line') }, + { value: 'T', label: t('blocks.styles.specials.terminal_station') }, ], }, ], @@ -210,7 +212,7 @@ const RailSignGenerator: React.FC = () => { - 块 {block.id} + {t('blocks.block')} {block.id}
- + {
diff --git a/src/components/window-header.tsx b/src/components/window-header.tsx index 1652cf7d..3e4c8e2e 100644 --- a/src/components/window-header.tsx +++ b/src/components/window-header.tsx @@ -12,7 +12,7 @@ export default function WindowHeader() { return ( - {'Rail Sign Generator'} + {t('head_bar.project_name')} diff --git a/src/i18n/translations/en.json b/src/i18n/translations/en.json index e2412d59..aa9545c9 100644 --- a/src/i18n/translations/en.json +++ b/src/i18n/translations/en.json @@ -1,11 +1,12 @@ { + "Help": "Help", "head_bar": { - "project_name": "Subway Signage Generator" + "project_name": "Rail Sign Generator" }, "main_area": { "preview": "Sign Preview", "new_block": "Add New Block", - "export_as_png": "Download as PNG", + "export_as_png": "Download PNG", "background_color": "Background Color" }, "blocks": { @@ -22,24 +23,34 @@ "line": "Line", "line_space": "Line + Space", "terminal_text": "Terminal Text", - "exit_texi": "Exit Text", - "special": "Unique Attributes", + "terminal_dest": "Terminal Station (To)", + "exit_text": "Exit Text", + "special": "Special Attributes", "specials": { "line_number": "Line Number", "line_color": "Line Color", "terminal_zh": "Terminal Station (Chinese)", "terminal_en": "Terminal Station (English)", "text_align": "Text Alignment", + "line_type": "Line Type", "align_right": "Align Right", "align_center": "Align Center", "align_left": "Align Left", "exit_letter": "Exit Number", "exit_lower": "Exit Subscript", "exit_zh": "Exit (Chinese)", - "exit_en": "Exit (English)" + "exit_en": "Exit (English)", + "normal_line": "Normal Line", + "loop_line": "Loop Line", + "terminal_station": "Terminal Station" } } }, + "prefixes": { + "to": "To", + "next_station": "Next Station", + "terminus": "Terminus" + }, "useful": { "yes": "Yes", "no": "No" diff --git a/src/i18n/translations/ja.json b/src/i18n/translations/ja.json index 48b0de3f..4b44e2f4 100644 --- a/src/i18n/translations/ja.json +++ b/src/i18n/translations/ja.json @@ -1,10 +1,11 @@ { + "Help": "ヘルプ", "head_bar": { "project_name": "地下鉄案内標識生成器" }, "main_area": { "preview": "標識プレビュー", - "new_block": "新しいブロックを追加", + "new_block": "+ 新しいブロックを追加", "export_as_png": "PNGとしてダウンロード", "background_color": "背景色" }, @@ -22,7 +23,8 @@ "line": "路線", "line_space": "路線 + スペース", "terminal_text": "終点テキスト", - "exit_texi": "出口テキスト", + "terminal_dest": "終点駅(行き先)", + "exit_text": "出口テキスト", "special": "独特な属性", "specials": { "line_number": "路線番号", @@ -30,16 +32,25 @@ "terminal_zh": "終点駅(中国語)", "terminal_en": "終点駅(英語)", "text_align": "テキストの配置", + "line_type": "路線タイプ", "align_right": "右寄せ", "align_center": "中央寄せ", "align_left": "左寄せ", "exit_letter": "出口番号", "exit_lower": "出口の下付き文字", "exit_zh": "出口(中国語)", - "exit_en": "出口(英語)" + "exit_en": "出口(英語)", + "normal_line": "通常路線", + "loop_line": "環状線", + "terminal_station": "終点駅" } } }, + "prefixes": { + "to": "行き", + "next_station": "次駅", + "terminus": "終点駅" + }, "useful": { "yes": "はい", "no": "いいえ" diff --git a/src/i18n/translations/ko.json b/src/i18n/translations/ko.json index e96a40ce..728dee79 100644 --- a/src/i18n/translations/ko.json +++ b/src/i18n/translations/ko.json @@ -1,10 +1,11 @@ { + "Help": "도움말", "head_bar": { "project_name": "지하철 안내 표지판 생성기" }, "main_area": { "preview": "표지판 미리보기", - "new_block": "새 블록 추가", + "new_block": "+ 새 블록 추가", "export_as_png": "PNG로 다운로드", "background_color": "배경색" }, @@ -22,7 +23,8 @@ "line": "노선", "line_space": "노선 + 공백", "terminal_text": "종점 텍스트", - "exit_texi": "출구 텍스트", + "terminal_dest": "종점역(행선지)", + "exit_text": "출구 텍스트", "special": "독특한 속성", "specials": { "line_number": "노선 번호", @@ -30,16 +32,25 @@ "terminal_zh": "종점 역(중국어)", "terminal_en": "종점 역(영어)", "text_align": "텍스트 정렬", + "line_type": "노선 유형", "align_right": "오른쪽 정렬", "align_center": "가운데 정렬", "align_left": "왼쪽 정렬", "exit_letter": "출구 번호", "exit_lower": "출구 아래 첨자", "exit_zh": "출구(중국어)", - "exit_en": "출구(영어)" + "exit_en": "출구(영어)", + "normal_line": "일반 노선", + "loop_line": "순환선", + "terminal_station": "종점역" } } }, + "prefixes": { + "to": "행", + "next_station": "다음역", + "terminus": "종점역" + }, "useful": { "yes": "예", "no": "아니오" diff --git a/src/i18n/translations/zh-Hans.json b/src/i18n/translations/zh-Hans.json index e8c05790..014c183c 100644 --- a/src/i18n/translations/zh-Hans.json +++ b/src/i18n/translations/zh-Hans.json @@ -1,17 +1,18 @@ { + "Help": "帮助", "head_bar": { "project_name": "地铁导视生成器" }, "main_area": { "preview": "标志预览", - "new_block": "添加新块", - "export_as_png": "下载png", + "new_block": "+ 添加新块", + "export_as_png": "下载PNG", "background_color": "背景颜色" }, "blocks": { "block": "块", - "cutline": "分割线(右)", - "styles":{ + "cutline": "分割线(右)", + "styles": { "style": "样式", "single_block": "单格", "two_block": "两格", @@ -22,7 +23,8 @@ "line": "线路", "line_space": "线路+空格", "terminal_text": "终点文字", - "exit_texi": "出口文字", + "terminal_dest": "终点站(开往)", + "exit_text": "出口文字", "special": "独特属性", "specials": { "line_number": "线路编号", @@ -30,16 +32,25 @@ "terminal_zh": "终点站中文", "terminal_en": "终点站英文", "text_align": "对齐方式", + "line_type": "线路类型", "align_right": "靠右对齐", "align_center": "居中对齐", "align_left": "靠左对齐", "exit_letter": "出口编号", "exit_lower": "出口下角标", "exit_zh": "出口中文", - "exit_en": "出口英文" + "exit_en": "出口英文", + "normal_line": "普通线", + "loop_line": "环线", + "terminal_station": "终点站" } } }, + "prefixes": { + "to": "开往", + "next_station": "下一站", + "terminus": "终点站" + }, "useful": { "yes": "是", "no": "否" diff --git a/src/i18n/translations/zh-Hant.json b/src/i18n/translations/zh-Hant.json index 4b7393c7..7ac34e87 100644 --- a/src/i18n/translations/zh-Hant.json +++ b/src/i18n/translations/zh-Hant.json @@ -1,16 +1,17 @@ { + "Help": "幫助", "head_bar": { "project_name": "地鐵導視生成器" }, "main_area": { "preview": "標誌預覽", - "new_block": "添加新塊", - "export_as_png": "下載png", + "new_block": "+ 添加新塊", + "export_as_png": "下載PNG", "background_color": "背景顏色" }, "blocks": { "block": "塊", - "cutline": "分割線(右)", + "cutline": "分割線(右)", "styles": { "style": "樣式", "single_block": "單格", @@ -22,7 +23,8 @@ "line": "線路", "line_space": "線路+空格", "terminal_text": "終點文字", - "exit_texi": "出口文字", + "terminal_dest": "終點站(開往)", + "exit_text": "出口文字", "special": "獨特屬性", "specials": { "line_number": "線路編號", @@ -30,16 +32,25 @@ "terminal_zh": "終點站中文", "terminal_en": "終點站英文", "text_align": "對齊方式", + "line_type": "線路類型", "align_right": "靠右對齊", "align_center": "居中對齊", "align_left": "靠左對齊", "exit_letter": "出口編號", "exit_lower": "出口下角標", "exit_zh": "出口中文", - "exit_en": "出口英文" + "exit_en": "出口英文", + "normal_line": "普通線", + "loop_line": "環線", + "terminal_station": "終點站" } } }, + "prefixes": { + "to": "開往", + "next_station": "下一站", + "terminus": "終點站" + }, "useful": { "yes": "是", "no": "否"