From 6b7faa07111eed339b0f0ef00fe995d73fb504ff Mon Sep 17 00:00:00 2001 From: SolitudeRA Date: Mon, 12 Jan 2026 06:15:09 +0900 Subject: [PATCH] feat: rss i18n --- src/components/common/RssSelector.tsx | 22 +++++++++++++-- src/components/layout/dock/DockNavMobile.tsx | 29 ++++++++++++++++++-- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/components/common/RssSelector.tsx b/src/components/common/RssSelector.tsx index e56c9fb..77bf2c1 100644 --- a/src/components/common/RssSelector.tsx +++ b/src/components/common/RssSelector.tsx @@ -19,6 +19,20 @@ const LOCALE_FLAGS: Record = { en: '🇺🇸', }; +// 多语言文本 +const UI_TEXTS = { + allLanguages: { + zh: '全部语言', + ja: 'すべての言語', + en: 'All Languages', + }, + current: { + zh: '当前', + ja: '現在', + en: 'Current', + }, +} as const; + // 默认语言 const DEFAULT_LOCALE: Locale = 'zh'; @@ -92,11 +106,15 @@ export default function RssSelector({ } }; + // 获取多语言文本 + const allLanguagesText = UI_TEXTS.allLanguages[currentLocale]; + const currentText = UI_TEXTS.current[currentLocale]; + // 生成 RSS 选项列表 const rssOptions: RssOption[] = [ { id: 'all', - label: '全部语言', + label: allLanguagesText, href: '/rss.xml', flag: '📡', }, @@ -168,7 +186,7 @@ export default function RssSelector({ {option.isCurrent && ( - 当前 + {currentText} )} diff --git a/src/components/layout/dock/DockNavMobile.tsx b/src/components/layout/dock/DockNavMobile.tsx index dd49ba7..61f9a8c 100644 --- a/src/components/layout/dock/DockNavMobile.tsx +++ b/src/components/layout/dock/DockNavMobile.tsx @@ -22,6 +22,20 @@ const LOCALE_FLAGS: Record = { en: '🇺🇸', }; +// 多语言文本 +const UI_TEXTS = { + allLanguages: { + zh: '全部语言', + ja: 'すべての言語', + en: 'All Languages', + }, + current: { + zh: '当前', + ja: '現在', + en: 'Current', + }, +} as const; + /** * 从当前 URL 中提取语言代码 */ @@ -80,10 +94,19 @@ export default function DockNavMobile() { setCurrentLocale(getCurrentLocale()); }, []); + // 获取多语言文本 + const allLanguagesText = UI_TEXTS.allLanguages[currentLocale]; + const currentText = UI_TEXTS.current[currentLocale]; + // RSS 选项列表 const rssOptions: RssOption[] = useMemo( () => [ - { id: 'all', label: '全部语言', href: '/rss.xml', flag: '📡' }, + { + id: 'all', + label: allLanguagesText, + href: '/rss.xml', + flag: '📡', + }, ...LOCALES.map((locale) => ({ id: locale, label: LOCALE_NAMES[locale], @@ -91,7 +114,7 @@ export default function DockNavMobile() { flag: LOCALE_FLAGS[locale], })), ], - [], + [allLanguagesText], ); // 根据当前语言构建导航链接 @@ -266,7 +289,7 @@ export default function DockNavMobile() { {option.id === currentLocale && ( - 当前 + {currentText} )}