Skip to content

Commit

Permalink
chore(i18n): add some i18n in zh (#616)
Browse files Browse the repository at this point in the history
* feat(i18n): add feed button

* feat(i18n): add shortcuts

* feat: add type I18nKeysForShortcuts
  • Loading branch information
ischanx authored Sep 26, 2024
1 parent da2e823 commit 6be812d
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 47 deletions.
8 changes: 8 additions & 0 deletions apps/renderer/src/constants/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@ export const shortcuts = {
},
},
} as const

export const shortcutsType: { [key in keyof typeof shortcuts]: I18nKeysForShortcuts } = {
feeds: "keys.type.feeds",
layout: "keys.type.layout",
entries: "keys.type.entries",
entry: "keys.type.entry",
audio: "keys.type.audio",
}
3 changes: 3 additions & 0 deletions apps/renderer/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import type { useTranslation } from "react-i18next"
const { t } = useTranslation()
// eslint-disable-next-line react-hooks/rules-of-hooks, unused-imports/no-unused-vars
const { t: settingsT } = useTranslation("settings")
// eslint-disable-next-line react-hooks/rules-of-hooks, unused-imports/no-unused-vars
const { t: shortcutsT } = useTranslation("shortcuts")
declare global {
export type Component<P = object> = FC<ComponentType & P>

Expand Down Expand Up @@ -38,6 +40,7 @@ declare global {

export type I18nKeys = OmitStringType<Parameters<typeof t>[0]>
export type I18nKeysForSettings = OmitStringType<Parameters<typeof settingsT>[0]>
export type I18nKeysForShortcuts = OmitStringType<Parameters<typeof shortcutsT>[0]>

type IsLiteralString<T> = T extends string ? (string extends T ? never : T) : never

Expand Down
4 changes: 2 additions & 2 deletions apps/renderer/src/modules/modal/shortcuts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { KbdCombined } from "~/components/ui/kbd/Kbd"
import { useCurrentModal, useModalStack } from "~/components/ui/modal"
import { PlainModal } from "~/components/ui/modal/stacked/custom-modal"
import { ScrollArea } from "~/components/ui/scroll-area"
import { shortcuts } from "~/constants/shortcuts"
import { shortcuts, shortcutsType } from "~/constants/shortcuts"
import { useSwitchHotKeyScope } from "~/hooks/common"
import { cn } from "~/lib/utils"

Expand Down Expand Up @@ -53,7 +53,7 @@ const ShortcutModalContent = () => {
<div className="w-full space-y-6 px-4 pb-5 pt-3">
{Object.keys(shortcuts).map((type) => (
<section key={type}>
<div className="mb-2 text-base font-medium capitalize">{type}</div>
<div className="mb-2 text-base font-medium capitalize">{t(shortcutsType[type])}</div>
<div className="rounded-md border text-[13px] text-zinc-600 dark:text-zinc-300">
{Object.keys(shortcuts[type]).map((action, index) => (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function Component() {
window.open(feedData.url, "_blank")
}}
>
View Feed URL
{t("feed.view_feed_url")}
</Button>
) : (
<Button
Expand All @@ -115,7 +115,7 @@ export function Component() {
navigator.clipboard.writeText(feedData.url)
}}
>
Copy Feed URL
{t("feed.copy_feed_url")}
</Button>
)}
<Button
Expand All @@ -127,7 +127,7 @@ export function Component() {
}}
>
<FollowIcon className="mr-1 size-3" />
{isSubscribed ? "Followed" : <>{APP_NAME}</>}
{isSubscribed ? t("feed.actions.followed") : <>{APP_NAME}</>}
</Button>
</span>
<div
Expand Down
4 changes: 2 additions & 2 deletions apps/renderer/src/pages/settings/(settings)/shortcuts.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useTranslation } from "react-i18next"

import { KbdCombined } from "~/components/ui/kbd/Kbd"
import { shortcuts } from "~/constants/shortcuts"
import { shortcuts, shortcutsType } from "~/constants/shortcuts"
import { cn } from "~/lib/utils"
import { SettingsTitle } from "~/modules/settings/title"
import { defineSettingPageData } from "~/modules/settings/utils"
Expand All @@ -23,7 +23,7 @@ export function Component() {
<div className="mt-4 space-y-6">
{Object.keys(shortcuts).map((type) => (
<section key={type}>
<div className="mb-2 text-sm font-medium capitalize">{type}</div>
<div className="mb-2 text-sm font-medium capitalize">{t(shortcutsType[type])}</div>
<div className="rounded-md border text-[13px] text-zinc-600 dark:text-zinc-300">
{Object.keys(shortcuts[type]).map((action, index) => (
<div
Expand Down
3 changes: 3 additions & 0 deletions locales/external/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"copied_link": "Copied link to clipboard",
"feed.actions.followed": "Followed",
"feed.copy_feed_url": "Copy Feed URL",
"feed.feeds_one": "feed",
"feed.feeds_other": "feeds",
"feed.follow_to_view_all": "Follow to view all {{count}} feeds...",
Expand All @@ -9,6 +11,7 @@
"feed.followsAndReads": "{{subscriptionCount}} {{subscriptionNoun}} with {{readCount}} {{readNoun}} on {{appName}}",
"feed.read_one": "read",
"feed.read_other": "reads",
"feed.view_feed_url": "View Feed URL",
"header.app": "App",
"header.download": "Download",
"invitation.activate": "Activate",
Expand Down
3 changes: 3 additions & 0 deletions locales/external/zh-CN.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"copied_link": "链接已复制到剪贴板",
"feed.actions.followed": "已订阅",
"feed.copy_feed_url": "复制链接",
"feed.feeds_one": "feed",
"feed.feeds_other": "feeds",
"feed.follow_to_view_all": "关注以查看所有的 {{count}} 个订阅...",
Expand All @@ -9,6 +11,7 @@
"feed.followsAndReads": "在 {{appName}} 上有 {{subscriptionCount}} 个{{subscriptionNoun}},{{readCount}} 篇{{readNoun}}",
"feed.read_one": "文章",
"feed.read_other": "文章",
"feed.view_feed_url": "查看链接",
"header.app": "应用",
"header.download": "下载",
"invitation.activate": "激活",
Expand Down
3 changes: 3 additions & 0 deletions locales/external/zh-HK.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"copied_link": "鏈接已複製到剪貼簿",
"feed.actions.followed": "已訂閲",
"feed.copy_feed_url": "複製鏈接",
"feed.feeds_one": "訂閲源",
"feed.feeds_other": "訂閲源",
"feed.follow_to_view_all": "跟隨以查看所有 {{count}} 個訂閲源...",
Expand All @@ -9,6 +11,7 @@
"feed.followsAndReads": "在 {{appName}} 上有 {{subscriptionCount}} 個 {{subscriptionNoun}} 和 {{readCount}} 個 {{readNoun}}",
"feed.read_one": "閱讀",
"feed.read_other": "閱讀數",
"feed.view_feed_url": "查看鏈接",
"header.app": "應用程式",
"header.download": "下載",
"invitation.activate": "激活",
Expand Down
76 changes: 36 additions & 40 deletions locales/external/zh-TW.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,39 @@
{
"copied_link": "連結已複製到剪貼簿",
"feed": {
"follower_one": "追隨者",
"follower_other": "追隨者",
"followsAndReads": "{{subscriptionCount}} 個 {{subscriptionNoun}} 和 {{readCount}} 個 {{readNoun}} 在 {{appName}}",
"read_one": "閱讀",
"read_other": "閱讀數"
},
"header": {
"app": "應用程式",
"download": "下載"
},
"invitation": {
"activate": "啟用",
"codeOptions": {
"1": "尋找任何內測用戶邀請您。",
"2": "加入我們的 Discord 伺服器,不定期贈送邀請碼。",
"3": "關注我們的 X 帳號,不定期贈送邀請碼。"
},
"earlyAccess": "Follow 目前處於搶先體驗階段,需要邀請碼才能使用。",
"earlyAccessMessage": "😰 抱歉,Follow 目前處於搶先體驗階段,需要邀請碼才能使用。",
"generateButton": "生成新邀請碼",
"generateCost": "您可以花費 {{INVITATION_PRICE}} 點 Power 為您的朋友生成邀請碼。",
"getCodeMessage": "您可以通過以下方式獲取邀請碼:",
"title": "邀請碼"
},
"login": {
"backToWebApp": "返回網頁應用程式",
"continueWithGitHub": "繼續使用 GitHub",
"continueWithGoogle": "繼續使用 Google",
"logInTo": "登入至 ",
"openApp": "開啟應用程式",
"redirecting": "正在重定向",
"welcomeTo": "歡迎來到 "
},
"redirect": {
"continueInBrowser": "在瀏覽器中繼續",
"instruction": "現在是時候打開 {{APP_NAME}} 並安全地關閉此頁面。",
"openApp": "開啟 {{APP_NAME}}",
"successMessage": "您已成功連接至 {{APP_NAME}} 帳戶。"
}
"feed.actions.followed": "已訂閲",
"feed.copy_feed_url": "複製鏈接",
"feed.feeds_one": "訂閲源",
"feed.feeds_other": "訂閲源",
"feed.follow_to_view_all": "跟隨以查看所有 {{count}} 個訂閲源...",
"feed.follower_one": "追隨者",
"feed.follower_other": "追隨者",
"feed.followsAndFeeds": "在 {{appName}} 上有 {{subscriptionCount}} 個 {{subscriptionNoun}} 和 {{feedsCount}} 個 {{feedsNoun}}",
"feed.followsAndReads": "{{subscriptionCount}} 個 {{subscriptionNoun}} 和 {{readCount}} 個 {{readNoun}} 在 {{appName}}",
"feed.read_one": "閱讀",
"feed.read_other": "閱讀數",
"feed.view_feed_url": "查看鏈接",
"header.app": "應用程式",
"header.download": "下載",
"invitation.activate": "啟用",
"invitation.codeOptions.1": "尋找任何內測用戶邀請您。",
"invitation.codeOptions.2": "加入我們的 Discord 伺服器,不定期贈送邀請碼。",
"invitation.codeOptions.3": "關注我們的 X 帳號,不定期贈送邀請碼。",
"invitation.earlyAccess": "Follow 目前處於搶先體驗階段,需要邀請碼才能使用。",
"invitation.earlyAccessMessage": "😰 抱歉,Follow 目前處於搶先體驗階段,需要邀請碼才能使用。",
"invitation.generateButton": "生成新邀請碼",
"invitation.generateCost": "您可以花費 {{INVITATION_PRICE}} 點 Power 為您的朋友生成邀請碼。",
"invitation.getCodeMessage": "您可以通過以下方式獲取邀請碼:",
"invitation.title": "邀請碼",
"login.backToWebApp": "返回網頁應用程式",
"login.continueWithGitHub": "繼續使用 GitHub",
"login.continueWithGoogle": "繼續使用 Google",
"login.logInTo": "登入至 ",
"login.openApp": "開啟應用程式",
"login.redirecting": "正在重定向",
"login.signOut": "登出",
"login.welcomeTo": "歡迎來到 ",
"redirect.continueInBrowser": "在瀏覽器中繼續",
"redirect.instruction": "現在是時候打開 {{APP_NAME}} 並安全地關閉此頁面。",
"redirect.openApp": "開啟 {{APP_NAME}}",
"redirect.successMessage": "您已成功連接至 {{APP_NAME}} 帳戶。"
}
5 changes: 5 additions & 0 deletions locales/shortcuts/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@
"keys.feeds.switchToView": "Switch to View",
"keys.layout.showShortcuts": "Show/Hide Shortcuts",
"keys.layout.toggleSidebar": "Show/Hide Feed Sidebar",
"keys.type.audio": "audio",
"keys.type.entries": "entries",
"keys.type.entry": "entry",
"keys.type.feeds": "feeds",
"keys.type.layout": "layout",
"sidebar_title": "Shortcuts"
}
5 changes: 5 additions & 0 deletions locales/shortcuts/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@
"keys.feeds.switchToView": "切换到指定类型",
"keys.layout.showShortcuts": "显示/隐藏快捷键",
"keys.layout.toggleSidebar": "显示/隐藏侧边栏",
"keys.type.audio": "音频",
"keys.type.entries": "条目列表",
"keys.type.entry": "条目",
"keys.type.feeds": "订阅源",
"keys.type.layout": "布局",
"sidebar_title": "快捷键"
}
5 changes: 5 additions & 0 deletions locales/shortcuts/zh-HK.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@
"keys.feeds.switchToView": "切換到視圖",
"keys.layout.showShortcuts": "顯示/隱藏快捷鍵",
"keys.layout.toggleSidebar": "顯示/隱藏訂閱側邊欄",
"keys.type.audio": "音頻",
"keys.type.entries": "條目列表",
"keys.type.entry": "條目",
"keys.type.feeds": "訂閲源",
"keys.type.layout": "佈局",
"sidebar_title": "快捷鍵"
}
5 changes: 5 additions & 0 deletions locales/shortcuts/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@
"keys.feeds.switchToView": "切換到視圖",
"keys.layout.showShortcuts": "顯示/隱藏快捷鍵",
"keys.layout.toggleSidebar": "顯示/隱藏摘要側邊欄",
"keys.type.audio": "音頻",
"keys.type.entries": "條目列表",
"keys.type.entry": "條目",
"keys.type.feeds": "訂閲源",
"keys.type.layout": "佈局",
"sidebar_title": "快捷鍵"
}

0 comments on commit 6be812d

Please sign in to comment.