Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/components/common/RssSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ const LOCALE_FLAGS: Record<Locale, string> = {
en: '🇺🇸',
};

// 多语言文本
const UI_TEXTS = {
allLanguages: {
zh: '全部语言',
ja: 'すべての言語',
en: 'All Languages',
},
current: {
zh: '当前',
ja: '現在',
en: 'Current',
},
} as const;

// 默认语言
const DEFAULT_LOCALE: Locale = 'zh';

Expand Down Expand Up @@ -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: '📡',
},
Expand Down Expand Up @@ -168,7 +186,7 @@ export default function RssSelector({
</span>
{option.isCurrent && (
<span className="text-primary text-xs">
当前
{currentText}
</span>
)}
</button>
Expand Down
29 changes: 26 additions & 3 deletions src/components/layout/dock/DockNavMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ const LOCALE_FLAGS: Record<Locale, string> = {
en: '🇺🇸',
};

// 多语言文本
const UI_TEXTS = {
allLanguages: {
zh: '全部语言',
ja: 'すべての言語',
en: 'All Languages',
},
current: {
zh: '当前',
ja: '現在',
en: 'Current',
},
} as const;

/**
* 从当前 URL 中提取语言代码
*/
Expand Down Expand Up @@ -80,18 +94,27 @@ 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],
href: `/${locale}/rss.xml`,
flag: LOCALE_FLAGS[locale],
})),
],
[],
[allLanguagesText],
);

// 根据当前语言构建导航链接
Expand Down Expand Up @@ -266,7 +289,7 @@ export default function DockNavMobile() {
{option.id ===
currentLocale && (
<span className="text-primary ml-auto text-xs">
当前
{currentText}
</span>
)}
</button>
Expand Down