diff --git a/apps/renderer/src/modules/discover/constants.ts b/apps/renderer/src/modules/discover/constants.ts index 7e87e410dd..0646af072e 100644 --- a/apps/renderer/src/modules/discover/constants.ts +++ b/apps/renderer/src/modules/discover/constants.ts @@ -1,101 +1,25 @@ -export const RSSHubCategoryOptions: { - name: string - value: string -}[] = [ - { - name: "All", - value: "all", - }, - { - name: "Social Media", - value: "social-media", - }, - { - name: "New Media", - value: "new-media", - }, - { - name: "News", - value: "traditional-media", - }, - { - name: "BBS", - value: "bbs", - }, - { - name: "Blog", - value: "blog", - }, - { - name: "Programming", - value: "programming", - }, - { - name: "Design", - value: "design", - }, - { - name: "Live", - value: "live", - }, - { - name: "Multimedia", - value: "multimedia", - }, - { - name: "Picture", - value: "picture", - }, - { - name: "ACG", - value: "anime", - }, - { - name: "Application Updates", - value: "program-update", - }, - { - name: "University", - value: "university", - }, - { - name: "Forecast", - value: "forecast", - }, - { - name: "Travel", - value: "travel", - }, - { - name: "Shopping", - value: "shopping", - }, - { - name: "Gaming", - value: "game", - }, - { - name: "Reading", - value: "reading", - }, - { - name: "Government", - value: "government", - }, - { - name: "Study", - value: "study", - }, - { - name: "Scientific Journal", - value: "journal", - }, - { - name: "Finance", - value: "finance", - }, -] - -export const RSSHubCategoryMap: Record = Object.fromEntries( - RSSHubCategoryOptions.map((item) => [item.value, item.name]), -) +export const RSSHubCategories = [ + "all", + "social-media", + "new-media", + "traditional-media", + "bbs", + "blog", + "programming", + "design", + "live", + "multimedia", + "picture", + "anime", + "program-update", + "university", + "forecast", + "travel", + "shopping", + "game", + "reading", + "government", + "study", + "journal", + "finance", +] as const diff --git a/apps/renderer/src/modules/discover/recommendations-card.tsx b/apps/renderer/src/modules/discover/recommendations-card.tsx index 3b33056a2d..fbe17b2c41 100644 --- a/apps/renderer/src/modules/discover/recommendations-card.tsx +++ b/apps/renderer/src/modules/discover/recommendations-card.tsx @@ -3,11 +3,12 @@ import clsx from "clsx" import { upperFirst } from "lodash-es" import type { FC } from "react" import { memo, useMemo } from "react" +import { useTranslation } from "react-i18next" import { useModalStack } from "~/components/ui/modal/stacked/hooks" import { FeedIcon } from "~/modules/feed/feed-icon" -import { RSSHubCategoryMap } from "./constants" +import { RSSHubCategories } from "./constants" import { RecommendationContent } from "./recommendation-content" import styles from "./recommendations.module.css" import type { RSSHubRouteDeclaration } from "./types" @@ -19,6 +20,7 @@ interface RecommendationCardProps { } export const RecommendationCard: FC = memo( ({ data, routePrefix, setCategory }) => { + const { t } = useTranslation() const { present } = useModalStack() const { maintainers, categories } = useMemo(() => { @@ -36,7 +38,7 @@ export const RecommendationCard: FC = memo( categories.delete("popular") return { maintainers: Array.from(maintainers), - categories: Array.from(categories), + categories: Array.from(categories) as typeof RSSHubCategories | string[], } }, [data]) @@ -130,17 +132,19 @@ export const RecommendationCard: FC = memo( {categories.map((c) => ( ))} diff --git a/apps/renderer/src/modules/discover/recommendations.tsx b/apps/renderer/src/modules/discover/recommendations.tsx index cef38ed257..7a117abaaf 100644 --- a/apps/renderer/src/modules/discover/recommendations.tsx +++ b/apps/renderer/src/modules/discover/recommendations.tsx @@ -19,7 +19,7 @@ import { useGeneralSettingKey } from "~/atoms/settings/general" import { useAuthQuery } from "~/hooks/common" import { Queries } from "~/queries" -import { RSSHubCategoryOptions } from "./constants" +import { RSSHubCategories } from "./constants" import styles from "./recommendations.module.css" import { RecommendationCard } from "./recommendations-card" @@ -35,7 +35,7 @@ const LanguageOptions = [ ] as const type Language = (typeof LanguageOptions)[number]["value"] -type DiscoverCategories = (typeof RSSHubCategoryOptions)[number]["value"] +type DiscoverCategories = (typeof RSSHubCategories)[number] | string const fetchRsshubPopular = (category: DiscoverCategories, lang: Language) => { return Queries.discover.rsshubCategory({ @@ -166,13 +166,9 @@ export function Recommendations({ > - {RSSHubCategoryOptions.map((category) => ( - - {category.name} + {RSSHubCategories.map((category) => ( + + {t(`discover.category.${category}`)} ))} diff --git a/apps/renderer/src/modules/entry-column/components/mark-all-button.tsx b/apps/renderer/src/modules/entry-column/components/mark-all-button.tsx index c1e76e7930..35e4d52b49 100644 --- a/apps/renderer/src/modules/entry-column/components/mark-all-button.tsx +++ b/apps/renderer/src/modules/entry-column/components/mark-all-button.tsx @@ -32,6 +32,7 @@ export const MarkAllReadWithOverlay = forwardRef< containerRef: React.RefObject } >(({ filter, className, which = "all", shortcut, containerRef }, ref) => { + const { t } = useTranslation() const { t: commonT } = useTranslation("common") const [show, setShow] = useState(false) @@ -63,7 +64,7 @@ export const MarkAllReadWithOverlay = forwardRef< action: { label: ( - Undo + {t("mark_all_read_button.undo")} Meta+Z diff --git a/locales/app/en.json b/locales/app/en.json index 17b7ed7951..2a39c39adb 100644 --- a/locales/app/en.json +++ b/locales/app/en.json @@ -39,6 +39,29 @@ "boost.feed_being_boosted": "Feed being boosted", "boost.remaining_boosts_to_level_up": "{{remainingBoostsToLevelUp}} more boost will unlock the next level of benefits!", "discover.any_url_or_keyword": "Any URL or Keyword", + "discover.category.all": "All", + "discover.category.anime": "ACG", + "discover.category.bbs": "BBS", + "discover.category.blog": "Blog", + "discover.category.design": "Design", + "discover.category.finance": "Finance", + "discover.category.forecast": "Forecast", + "discover.category.game": "Gaming", + "discover.category.government": "Government", + "discover.category.journal": "Scientific Journal", + "discover.category.live": "Live", + "discover.category.multimedia": "Multimedia", + "discover.category.new-media": "New Media", + "discover.category.picture": "Picture", + "discover.category.program-update": "Application Updates", + "discover.category.programming": "Programming", + "discover.category.reading": "Reading", + "discover.category.shopping": "Shopping", + "discover.category.social-media": "Social Media", + "discover.category.study": "Study", + "discover.category.traditional-media": "News", + "discover.category.travel": "Travel", + "discover.category.university": "University", "discover.default_option": " (default)", "discover.feed_description": "The description of this feed is as follows, and you can fill out the parameter form with the relevant information.", "discover.feed_maintainers": "This feed is provided by RSSHub, with credit to ", diff --git a/locales/app/zh-CN.json b/locales/app/zh-CN.json index 1b16c0ebdb..bb33a68cf0 100644 --- a/locales/app/zh-CN.json +++ b/locales/app/zh-CN.json @@ -39,6 +39,29 @@ "boost.feed_being_boosted": "已助力", "boost.remaining_boosts_to_level_up": "再助力 {{remainingBoostsToLevelUp}} 次即可解锁下一级福利!", "discover.any_url_or_keyword": "任意链接或关键词", + "discover.category.all": "全部", + "discover.category.anime": "二次元", + "discover.category.bbs": "论坛", + "discover.category.blog": "博客", + "discover.category.design": "设计", + "discover.category.finance": "金融", + "discover.category.forecast": "预报预警", + "discover.category.game": "游戏", + "discover.category.government": "政务消息", + "discover.category.journal": "科学期刊", + "discover.category.live": "直播", + "discover.category.multimedia": "音视频", + "discover.category.new-media": "新媒体", + "discover.category.picture": "图片", + "discover.category.program-update": "程序更新", + "discover.category.programming": "编程", + "discover.category.reading": "阅读", + "discover.category.shopping": "购物", + "discover.category.social-media": "社交媒体", + "discover.category.study": "学习", + "discover.category.traditional-media": "传统媒体", + "discover.category.travel": "出行旅游", + "discover.category.university": "大学通知", "discover.default_option": " (默认)", "discover.feed_description": "根据描述完善目标订阅源的相关信息", "discover.feed_maintainers": "由 RSSHub 提供,感谢贡献者 ",