Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add more words i18n #516

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from
19 changes: 15 additions & 4 deletions apps/renderer/src/hooks/biz/useSubscriptionActions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useMutation } from "@tanstack/react-query"
import { useHotkeys } from "react-hotkeys-hook"
import { Trans, useTranslation } from "react-i18next"
import { toast } from "sonner"

import { Kbd } from "~/components/ui/kbd/Kbd"
Expand All @@ -13,8 +14,10 @@ import { feedUnreadActions } from "~/store/unread"
import { navigateEntry } from "./useNavigateEntry"
import { getRouteParams } from "./useRouteParams"

export const useDeleteSubscription = ({ onSuccess }: { onSuccess?: () => void }) =>
useMutation({
export const useDeleteSubscription = ({ onSuccess }: { onSuccess?: () => void }) => {
const { t } = useTranslation("app")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { t } = useTranslation("app")
const { t } = useTranslation()


return useMutation({
mutationFn: async (subscription: SubscriptionFlatModel) =>
subscriptionActions.unfollow(subscription.feedId).then((feed) => {
subscriptionQuery.byView(subscription.view).invalidate()
Expand All @@ -38,12 +41,13 @@ export const useDeleteSubscription = ({ onSuccess }: { onSuccess?: () => void })

toast.dismiss(toastId)
}

const toastId = toast(<UnfollowInfo title={feed.title!} undo={undo} />, {
duration: 3000,
action: {
label: (
<span className="flex items-center gap-1">
Undo
{t("words.undo")}
<Kbd className="inline-flex items-center border border-border bg-transparent dark:text-white">
Meta+Z
</Kbd>
Expand All @@ -67,6 +71,7 @@ export const useDeleteSubscription = ({ onSuccess }: { onSuccess?: () => void })
}
},
})
}

const UnfollowInfo = ({ title, undo }: { title: string; undo: () => any }) => {
useHotkeys("ctrl+z,meta+z", undo, {
Expand All @@ -75,7 +80,13 @@ const UnfollowInfo = ({ title, undo }: { title: string; undo: () => any }) => {
})
return (
<>
Feed <i className="mr-px font-semibold">{title}</i> has been unfollowed.
<Trans
ns="app"
i18nKey="notify.unfollow_feed"
components={{
FeedItem: <i className="mr-px font-semibold">{title}</i>,
}}
/>
</>
)
}
4 changes: 3 additions & 1 deletion apps/renderer/src/modules/claim/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createElement, useCallback } from "react"
import { useTranslation } from "react-i18next"

import { useModalStack } from "~/components/ui/modal/stacked/hooks"
import { getFeedById } from "~/store/feed"
Expand All @@ -7,6 +8,7 @@ import { FeedClaimModalContent } from "./feed-claim-modal"

export const useFeedClaimModal = ({ feedId }: { feedId?: string }) => {
const { present } = useModalStack()
const { t } = useTranslation("app")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { t } = useTranslation("app")
const { t } = useTranslation()


return useCallback(() => {
if (!feedId) return
Expand All @@ -16,7 +18,7 @@ export const useFeedClaimModal = ({ feedId }: { feedId?: string }) => {
if (!feed) return

present({
title: "Feed Claim",
title: t("feed_claim_modal.title"),
content: () => createElement(FeedClaimModalContent, { feedId }),
modalClassName: "!h-auto !max-h-screen",
})
Expand Down
36 changes: 18 additions & 18 deletions apps/renderer/src/modules/discover/import.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { zodResolver } from "@hookform/resolvers/zod"
import { useMutation } from "@tanstack/react-query"
import { Fragment } from "react/jsx-runtime"
import { useForm } from "react-hook-form"
import { useTranslation } from "react-i18next"
import { Trans, useTranslation } from "react-i18next"
import { z } from "zod"

import { Button } from "~/components/ui/button"
Expand Down Expand Up @@ -36,20 +36,22 @@ const formSchema = z.object({
}),
})

const NumberDisplay = ({ value }) => <span className="font-bold text-zinc-800">{value ?? 0}</span>

const list = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const list = [
const list: {
key: I18nKeys;
title: string;
className: string;
}[] = [

{
key: "parsedErrorItems",
title: "Parsed Error Items",
jerryc127 marked this conversation as resolved.
Show resolved Hide resolved
title: <Trans ns="app" i18nKey="discover.import.parsedErrorItems" />,
className: "text-red-500",
},
{
key: "successfulItems",
title: "Successful Items",
title: <Trans ns="app" i18nKey="discover.import.successfulItems" />,
className: "text-green-500",
},
{
key: "conflictItems",
title: "Conflict Items",
title: <Trans ns="app" i18nKey="discover.import.conflictItems" />,
className: "text-yellow-500",
},
]
Expand Down Expand Up @@ -89,6 +91,7 @@ export function DiscoverImport() {
function onSubmit(values: z.infer<typeof formSchema>) {
mutation.mutate(values.file)
}

const { t } = useTranslation()

return (
Expand All @@ -100,7 +103,7 @@ export function DiscoverImport() {
name="file"
render={({ field: { value, onChange, ...fieldProps } }) => (
<FormItem>
<FormLabel>OPML file</FormLabel>
<FormLabel>{t("discover.import.opml")}</FormLabel>
<FormControl>
<label
className="center flex h-[100px] w-full rounded-md border border-dashed"
Expand Down Expand Up @@ -150,26 +153,23 @@ export function DiscoverImport() {
<div className="mt-8 max-w-lg">
<Card>
<CardHeader className="block text-zinc-500">
<span className="font-bold text-zinc-800">
{mutation.data?.successfulItems.length || 0}
</span>{" "}
feeds were successfully imported,{" "}
<span className="font-bold text-zinc-800">
{mutation.data?.conflictItems.length || 0}
</span>{" "}
were already subscribed to, and{" "}
<span className="font-bold text-zinc-800">
{mutation.data?.parsedErrorItems.length || 0}
</span>{" "}
failed to import.
<Trans
ns="app"
i18nKey="discover.import.result"
components={{
SuccessfulNum: <NumberDisplay value={mutation.data?.successfulItems.length} />,
ConflictNum: <NumberDisplay value={mutation.data?.conflictItems.length} />,
ErrorNum: <NumberDisplay value={mutation.data?.parsedErrorItems.length} />,
}}
/>
</CardHeader>
<CardContent className="space-y-6">
{list.map((item) => (
<div key={item.key}>
<div className={cn("mb-4 text-lg font-medium", item.className)}>{item.title}</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div className={cn("mb-4 text-lg font-medium", item.className)}>{item.title}</div>
<div className={cn("mb-4 text-lg font-medium", item.className)}>{t(item.title)}</div>

<div className="space-y-4">
{!mutation.data?.[item.key].length && (
<div className="text-zinc-500">No items</div>
<div className="text-zinc-500">{t("discover.import.noItems")}</div>
)}
{mutation.data?.[item.key].map((feed: FeedResponse) => (
<FollowSummary className="max-w-[462px]" key={feed.id} feed={feed} />
Expand Down
19 changes: 5 additions & 14 deletions apps/renderer/src/modules/entry-content/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { repository } from "@pkg"
import type { FallbackRender } from "@sentry/react"
import { ErrorBoundary } from "@sentry/react"
import type { FC } from "react"
Expand Down Expand Up @@ -413,28 +412,20 @@ const NoContent: FC<{
url: string
}> = ({ id, url }) => {
const status = useEntryInReadabilityStatus(id)
const { t } = useTranslation("app")

if (status !== ReadabilityStatus.INITIAL && status !== ReadabilityStatus.FAILURE) {
return null
}
return (
<div className="center">
<div className="space-y-2 text-balance text-center text-sm text-zinc-400">
{(isWebBuild || status === ReadabilityStatus.FAILURE) && <span>No content</span>}
{(isWebBuild || status === ReadabilityStatus.FAILURE) && (
<span>{t("entry_content.no_content")}</span>
)}
{isWebBuild && (
<div>
<span>
Maybe web app doesn't support this content type. But you can{" "}
<a
target="_blank"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why deleted

rel="noreferrer"
className="text-accent underline"
href={`${repository.url}/releases`}
>
download
</a>{" "}
the desktop app.
</span>
<span>{t("entry_content.web_app_notice")}</span>
</div>
)}
{url && window.electron && <ReadabilityAutoToggle url={url} id={id} />}
Expand Down
2 changes: 1 addition & 1 deletion apps/renderer/src/modules/feed-column/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function FeedListImpl({ className, view }: { className?: string; view: number })
onClick={stopPropagation}
>
<i className="i-mgc-add-cute-re text-3xl" />
<span className="text-base">Add some feeds</span>
<span className="text-base">{t("sidebar.add_more_feeds")}</span>
</Link>
</div>
)}
Expand Down
10 changes: 10 additions & 0 deletions locales/app/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
"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 <maintainers />",
"discover.import.click_to_upload": "Click to upload OPML file",
"discover.import.conflictItems": "Conflict Items",
"discover.import.noItems": "No items",
"discover.import.opml": "OPML file",
"discover.import.parsedErrorItems": "Parsed Error Items",
"discover.import.result": "<SuccessfulNum /> feeds were successfully imported, <ConflictNum /> were already subscribed to, and <ErrorNum /> failed to import.",
"discover.import.successfulItems": "Successful Items",
"discover.popular": "Popular",
"discover.preview": "Preview",
"discover.rss_hub_route": "RSSHub Route",
Expand Down Expand Up @@ -76,6 +82,7 @@
"feed_claim_modal.tab_content": "Content",
"feed_claim_modal.tab_description": "Description",
"feed_claim_modal.tab_rss": "RSS Tag",
"feed_claim_modal.title": "Feed Claim",
"feed_claim_modal.verify_ownership": "To claim this feed as your own, you need to verify ownership.",
"feed_form.add_follow": "Add follow",
"feed_form.category": "Category",
Expand Down Expand Up @@ -114,6 +121,7 @@
"mark_all_read_button.mark_all_as_read": "Mark all as read",
"mark_all_read_button.mark_as_read": "Mark {{which}} as read",
"mark_all_read_button.undo": "Undo",
"notify.unfollow_feed": "<FeedItem /> have been unfollowed.",
"player.back_10s": "Back 10s",
"player.close": "Close",
"player.download": "Download",
Expand All @@ -138,6 +146,7 @@
"search.result_count_local_mode": "(Local mode)",
"search.tooltip.local_search": "This search covers locally available data. Try a Refetch to include the latest data.",
"shortcuts.guide.title": "Shortcuts Guideline",
"sidebar.add_more_feeds": "Add more feeds",
"sidebar.category_remove_dialog.cancel": "Cancel",
"sidebar.category_remove_dialog.continue": "Continue",
"sidebar.category_remove_dialog.description": "This operation will delete your category, but the feeds it contains will be retained and grouped by website.",
Expand Down Expand Up @@ -203,6 +212,7 @@
"words.rsshub": "RSSHub",
"words.search": "Search",
"words.starred": "Starred",
"words.undo": "Undo",
"words.unread": "Unread",
"words.user": "User",
"words.which.all": "all",
Expand Down
10 changes: 10 additions & 0 deletions locales/app/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
"discover.feed_description": "根据描述完善目标订阅源的相关信息",
"discover.feed_maintainers": "由 RSSHub 提供,感谢贡献者 <maintainers />",
"discover.import.click_to_upload": "导入 OPML 文件",
"discover.import.conflictItems": "冲突项目",
"discover.import.noItems": "没有项目",
"discover.import.opml": "OPML 文件",
"discover.import.parsedErrorItems": "解析错误项目",
"discover.import.result": "成功导入了 <SuccessfulNum /> 个订阅源,<ConflictNum /> 个已订阅,<ErrorNum /> 个导入失败。",
"discover.import.successfulItems": "成功项目",
"discover.popular": "热门",
"discover.preview": "预览",
"discover.rss_hub_route": "RSSHub 路由",
Expand Down Expand Up @@ -76,6 +82,7 @@
"feed_claim_modal.tab_content": "内容",
"feed_claim_modal.tab_description": "描述",
"feed_claim_modal.tab_rss": "RSS 标签",
"feed_claim_modal.title": "认证订阅源",
"feed_claim_modal.verify_ownership": "完成订阅源所有权验证,证明该源由你提供",
"feed_form.add_follow": "新增订阅",
"feed_form.category": "分类",
Expand Down Expand Up @@ -114,6 +121,7 @@
"mark_all_read_button.mark_all_as_read": "全部标记为已读",
"mark_all_read_button.mark_as_read": "标记{{which}}为已读",
"mark_all_read_button.undo": "撤销",
"notify.unfollow_feed": "已取消订阅 <FeedItem />",
"player.back_10s": "后退 10s",
"player.close": "关闭",
"player.download": "下载",
Expand All @@ -138,6 +146,7 @@
"search.result_count_local_mode": "(本地模式)",
"search.tooltip.local_search": "当前搜索仅包含本地可用数据,尝试重新搜索得到更多结果",
"shortcuts.guide.title": "快捷键指南",
"sidebar.add_more_feeds": "添加订阅源",
"sidebar.category_remove_dialog.cancel": "取消",
"sidebar.category_remove_dialog.continue": "继续",
"sidebar.category_remove_dialog.description": "正在删除分类,操作后仍保留订阅源并按网站分组",
Expand Down Expand Up @@ -203,6 +212,7 @@
"words.rsshub": "RSSHub",
"words.search": "搜索",
"words.starred": "收藏",
"words.undo": "撤销",
"words.unread": "未读",
"words.user": "用户",
"words.which.all": "全部",
Expand Down
10 changes: 10 additions & 0 deletions locales/app/zh-HK.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
"discover.feed_description": "此訂閱源的描述如下,你可以根據相關資訊填寫參數表格。",
"discover.feed_maintainers": "此訂閱源由 RSSHub 提供,感謝 <maintainers />",
"discover.import.click_to_upload": "上傳 OPML 文件",
"discover.import.conflictItems": "衝突項目",
"discover.import.noItems": "沒有項目",
"discover.import.opml": "OPML 文件",
"discover.import.parsedErrorItems": "解析錯誤項目",
"discover.import.result": "<SuccessfulNum /> 個訂閱源已成功導入,<ConflictNum /> 個已訂閱,<ErrorNum /> 個導入失敗。",
"discover.import.successfulItems": "成功項目",
"discover.popular": "熱門",
"discover.preview": "預覽",
"discover.rss_hub_route": "RSSHub 路由",
Expand Down Expand Up @@ -76,6 +82,7 @@
"feed_claim_modal.tab_content": "內容",
"feed_claim_modal.tab_description": "描述",
"feed_claim_modal.tab_rss": "RSS 標籤",
"feed_claim_modal.title": "認領訂閱源",
"feed_claim_modal.verify_ownership": "要認領這個訂閱源,你需要驗證所有權。",
"feed_form.add_follow": "新增關注",
"feed_form.category": "分類",
Expand Down Expand Up @@ -114,6 +121,7 @@
"mark_all_read_button.mark_all_as_read": "全部標記為已讀",
"mark_all_read_button.mark_as_read": "標記 {{which}} 為已讀",
"mark_all_read_button.undo": "撤銷",
"notify.unfollow_feed": "已取消關注 <FeedItem />。",
"player.back_10s": "倒退 10 秒",
"player.close": "關閉",
"player.download": "下載",
Expand All @@ -138,6 +146,7 @@
"search.result_count_local_mode": "(本地模式)",
"search.tooltip.local_search": "此搜尋涵蓋本地可用的數據。嘗試重新獲取以包括最新數據。",
"shortcuts.guide.title": "快捷鍵指南",
"sidebar.add_more_feeds": "添加訂閱源",
"sidebar.category_remove_dialog.cancel": "取消",
"sidebar.category_remove_dialog.continue": "繼續",
"sidebar.category_remove_dialog.description": "此操作將刪除你的分類,但其中的訂閱源將保留並按網站分組。",
Expand Down Expand Up @@ -203,6 +212,7 @@
"words.rsshub": "RSSHub",
"words.search": "搜尋",
"words.starred": "收藏",
"words.undo": "撤銷",
"words.unread": "未讀",
"words.user": "用戶",
"words.which.all": "所有",
Expand Down
10 changes: 10 additions & 0 deletions locales/app/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
"discover.feed_description": "該 feed 的描述如下,您可以使用相關資訊填寫參數表單。",
"discover.feed_maintainers": "此 feed 由 RSSHub 提供,感謝 <maintainers /> 的支持",
"discover.import.click_to_upload": "點擊上傳 OPML 文件",
"discover.import.conflictItems": "衝突項目",
"discover.import.noItems": "沒有項目",
"discover.import.opml": "OPML 檔案",
"discover.import.parsedErrorItems": "解析錯誤項目",
"discover.import.result": "成功匯入了 <SuccessfulNum /> 個訂閱源,<ConflictNum /> 個已經訂閱,<ErrorNum /> 個匯入失敗。",
"discover.import.successfulItems": "成功項目",
"discover.popular": "熱門",
"discover.preview": "預覽",
"discover.rss_hub_route": "RSSHub 路由",
Expand Down Expand Up @@ -76,6 +82,7 @@
"feed_claim_modal.tab_content": "內容",
"feed_claim_modal.tab_description": "描述",
"feed_claim_modal.tab_rss": "RSS 標籤",
"feed_claim_modal.title": "認領摘要",
"feed_claim_modal.verify_ownership": "要認領此摘要為您的內容,您需要驗證所有權。",
"feed_form.add_follow": "關注",
"feed_form.category": "類別",
Expand Down Expand Up @@ -114,6 +121,7 @@
"mark_all_read_button.mark_all_as_read": "全部標記為已讀",
"mark_all_read_button.mark_as_read": "將 {{which}} 標記為已讀",
"mark_all_read_button.undo": "復原",
"notify.unfollow_feed": "已取消關注 <FeedItem />",
"player.back_10s": "後退 10 秒",
"player.close": "關閉",
"player.download": "下載",
Expand All @@ -138,6 +146,7 @@
"search.result_count_local_mode": "(本地模式)",
"search.tooltip.local_search": "此搜尋涵蓋本地可用資料。嘗試重新獲取以包含最新資料。",
"shortcuts.guide.title": "快捷鍵指南",
"sidebar.add_more_feeds": "添加摘要",
"sidebar.category_remove_dialog.cancel": "取消",
"sidebar.category_remove_dialog.continue": "繼續",
"sidebar.category_remove_dialog.description": "此操作將刪除您的類別,但它包含的摘要將被保留並按網站分組。",
Expand Down Expand Up @@ -203,6 +212,7 @@
"words.rsshub": "RSSHub",
"words.search": "搜尋",
"words.starred": "收藏",
"words.undo": "撤銷",
"words.unread": "未讀",
"words.user": "使用者",
"words.which.all": "全部",
Expand Down
Loading
Loading