feat(i18n): split locale dicts into src/locales/ and add full Korean translation

- Extract zhDict/enDict from i18n.tsx into src/locales/{zh-CN,en}.ts
- Add full Korean dictionary (src/locales/ko.ts) covering all 115 UI keys
- Update formatBytes test/impl boundary for 1000-based units
This commit is contained in:
TerryM
2026-06-01 15:49:15 +08:00
parent c490524575
commit 337d19e626
7 changed files with 407 additions and 271 deletions

View File

@@ -6,269 +6,13 @@ import React, {
useState,
} from "react";
import { languageForHomePathname } from "./languageRoutes";
import type { Dict } from "./locales/types";
import { zhDict } from "./locales/zh-CN";
import { enDict } from "./locales/en";
import { koDict } from "./locales/ko";
export type Lang = "zh-CN" | "en" | "ja" | "ko" | "vi" | "id" | "ms";
type Dict = Record<string, string>;
const zhDict: Dict = {
brand: "ARK 资料库",
mainNav: "网站导航",
home: "首页",
all: "全部资料",
categories: "资料分类",
latest: "最新更新",
official: "官方推荐",
popular: "热门资料",
search: "搜索",
searchPlaceholder: "搜索资料...",
searchPanelPlaceholder: "搜索资料...",
searchNow: "立即搜索资料",
searchSubmit: "搜索",
cancel: "取消",
clear: "清除",
searchPanelHint: "支持搜索 标题・分类・标签・简介・文件类型・正文",
currentTags: "现有标签",
noTagsAvailable: "暂无可选择的标签。",
tagPostsTitle: "#{{tag}} 相关资料",
noTagPosts: "暂时找不到带有此标签的资料。",
viewAll: "查看全部",
backToTop: "回到顶部",
heroTitle: "ARK 官方数据库",
heroSub:
"集中、分类、管理 ARK 数据库,让你快速找到所需资源,推动社群共识与成长。",
categorySection: "资料分类",
officialSection: "官方推荐",
latestSection: "最新更新",
popularSection: "热门资料",
preview: "预览",
download: "下载",
downloading: "下载中…",
downloadOk: "下载完成",
downloadFail: "下载失败,请重试",
longPressImageSave: "长按图片保存到相册",
showMore: "展开全部",
showLess: "收起全部",
share: "分享",
langLabel: "语言",
admin: "后台",
login: "登录",
logout: "退出",
email: "邮箱",
password: "密码",
dashboard: "仪表盘",
resources: "资料管理",
newResource: "新增资料",
save: "保存",
title: "标题",
description: "简介",
type: "类型",
language: "语言",
category: "分类",
status: "状态",
public: "公开",
downloadable: "可下载",
recommended: "首页推荐",
cover: "封面图 URL",
fileUrl: "文件 URL",
externalUrl: "外部链接",
body: "文案内容",
badge: "推荐标签",
published: "已发布",
draft: "草稿",
archived: "归档",
noResults: "找不到符合的资料,请换个关键字或浏览分类。",
copyLink: "复制链接",
related: "相关资料",
total: "总资料",
views: "浏览",
downloads: "下载",
lang_zh_CN: "中文",
lang_en: "English",
lang_ja: "日本語",
lang_ko: "한국어",
lang_vi: "Tiếng Việt",
lang_id: "Bahasa Indonesia",
lang_ms: "Bahasa Melayu",
filterAll: "全部",
sortPublished: "发布时间",
type_ppt: "PPT",
type_music: "音乐",
type_video: "视频",
type_image: "图片",
type_pdf: "PDF",
type_link: "链接",
type_text: "文字",
type_archive: "压缩包",
type_zip: "ZIP",
adminLoginTitle: "管理后台登录",
adminEditResource: "编辑资料",
adminVideoFileHint:
"上传视频文件MP4/WebM/MOV 等),类型请选择「视频」;保存后前台自动播放(默认静音,可点喇叭开声音)。",
adminStatTodayNew: "今日新增",
adminStatFavorites: "收藏",
adminMetricDownloads: "下载",
adminMetricFavorites: "收藏",
adminMetricViews: "浏览",
edit: "编辑",
backToList: "返回列表",
sortOrderLabel: "排序权重",
previewUrlLabel: "预览网址",
tagsCommaLabel: "标签(逗号分隔)",
uploadFile: "上传文件",
loading: "加载中…",
paginationPrev: "上一页",
paginationNext: "下一页",
listRange: "显示 {{from}}{{to}},共 {{total}} 条",
pageIndicator: "{{c}} / {{p}} 页",
resourceLangFilter: "资料语言",
filterTagClear: "清除标签",
filterLanguageAll: "全部语言",
footerAdminLogin: "管理员登录",
adminSearchLogs: "搜索记录",
adminMetricShares: "分享",
adminSearchQuery: "查询词",
adminSearchTime: "时间",
adminSearchId: "编号",
favorites: "我的收藏",
favoritesComingSoon: "功能即将推出",
favoritesComingSoonDesc: "登入与收藏功能开发中,敬请期待。",
featureUnavailable: "未开放",
featureUnavailableDesc: "该功能暂未开放。",
confirm: "知道了",
backToHome: "返回首页",
};
const enDict: Dict = {
brand: "ARK Library",
mainNav: "Site menu",
home: "Home",
all: "All assets",
categories: "Categories",
latest: "Latest",
official: "Official picks",
popular: "Popular",
search: "Search",
searchPlaceholder: "Search resources...",
searchPanelPlaceholder: "Search assets...",
searchNow: "Search now",
searchSubmit: "Search",
cancel: "Cancel",
clear: "Clear",
searchPanelHint:
"Search supports title, category, tags, summary, file type, and body text.",
currentTags: "Available tags",
noTagsAvailable: "No tags available yet.",
tagPostsTitle: "#{{tag}} related posts",
noTagPosts: "No posts with this tag yet.",
viewAll: "View all",
backToTop: "Back to top",
heroTitle: "ARK Official Library",
heroSub:
"Centralize, organize, and manage the ARK library so you can find what you need fast and help the community grow together.",
categorySection: "Categories",
officialSection: "Official recommendations",
latestSection: "Latest updates",
popularSection: "Popular assets",
preview: "Preview",
download: "Download",
downloading: "Downloading…",
downloadOk: "Download complete",
downloadFail: "Download failed, please retry",
longPressImageSave: "Long-press image to save",
showMore: "Show all",
showLess: "Show less",
share: "Share",
langLabel: "Language",
admin: "Admin",
login: "Sign in",
logout: "Sign out",
email: "Email",
password: "Password",
dashboard: "Dashboard",
resources: "Resources",
newResource: "New resource",
save: "Save",
title: "Title",
description: "Description",
type: "Type",
language: "Language",
category: "Category",
status: "Status",
public: "Public",
downloadable: "Downloadable",
recommended: "Featured",
cover: "Cover image URL",
fileUrl: "File URL",
externalUrl: "External URL",
body: "Text body",
badge: "Badge label",
published: "Published",
draft: "Draft",
archived: "Archived",
noResults: "No results. Try another keyword or browse categories.",
copyLink: "Copy link",
related: "Related",
total: "Total items",
views: "Views",
downloads: "Downloads",
lang_zh_CN: "Chinese",
lang_en: "English",
lang_ja: "Japanese",
lang_ko: "Korean",
lang_vi: "Vietnamese",
lang_id: "Indonesian",
lang_ms: "Malay",
filterAll: "All types",
sortPublished: "Published date",
type_ppt: "PPT",
type_music: "Music",
type_video: "Video",
type_image: "Image",
type_pdf: "PDF",
type_link: "Link",
type_text: "Text",
type_archive: "Archive",
type_zip: "ZIP",
adminLoginTitle: "Admin sign in",
adminEditResource: "Edit resource",
adminVideoFileHint:
"Upload a video file (MP4/WebM/MOV, etc.) and set type to Video; the site will autoplay (muted by default — user can unmute).",
adminStatTodayNew: "New today",
adminStatFavorites: "Favorites",
adminMetricDownloads: "Downloads",
adminMetricFavorites: "Favorites",
adminMetricViews: "Views",
edit: "Edit",
backToList: "Back to list",
sortOrderLabel: "Sort order",
previewUrlLabel: "Preview URL",
tagsCommaLabel: "Tags (comma-separated)",
uploadFile: "Upload",
loading: "Loading…",
paginationPrev: "Previous",
paginationNext: "Next",
listRange: "Showing {{from}}{{to}} of {{total}}",
pageIndicator: "Page {{c}} / {{p}}",
resourceLangFilter: "Resource language",
filterTagClear: "Clear tag",
filterLanguageAll: "All languages",
footerAdminLogin: "Admin sign-in",
adminSearchLogs: "Search logs",
adminMetricShares: "Shares",
adminSearchQuery: "Query",
adminSearchTime: "Time",
adminSearchId: "ID",
favorites: "My Favorites",
favoritesComingSoon: "Coming Soon",
favoritesComingSoonDesc:
"Sign-in and favorites are in development. Stay tuned.",
featureUnavailable: "Not available yet",
featureUnavailableDesc: "This feature is not available yet.",
confirm: "Got it",
backToHome: "Back to Home",
};
const languageNames: Record<Lang, Dict> = {
"zh-CN": {
lang_zh_CN: "中文",
@@ -354,7 +98,7 @@ const dict: Record<Lang, Dict> = {
"zh-CN": { ...zhDict, ...languageNames["zh-CN"] },
en: { ...enDict, ...languageNames.en },
ja: { ...enDict, ...languageNames.ja },
ko: { ...enDict, ...languageNames.ko },
ko: koDict,
vi: { ...enDict, ...languageNames.vi },
id: { ...enDict, ...languageNames.id },
ms: { ...enDict, ...languageNames.ms },