Skip to content

Commit

Permalink
feat: support i18n (#345)
Browse files Browse the repository at this point in the history
* add i18next

* language selector

* add chinese translation to general settings

* fix: type error

Signed-off-by: Innei <i@innei.in>

* fix: selection style

Signed-off-by: Innei <i@innei.in>

* refactor: init i18n and language map

Signed-off-by: Innei <i@innei.in>

* feat: intelligence

Signed-off-by: Innei <i@innei.in>

* refactor: i18n dx hmr

Signed-off-by: Innei <i@innei.in>

* chore: lockfile

Signed-off-by: Innei <i@innei.in>

* chore: code style

Signed-off-by: Innei <i@innei.in>

* cleanup

Signed-off-by: Innei <i@innei.in>

---------

Signed-off-by: Innei <i@innei.in>
Co-authored-by: Innei <i@innei.in>
  • Loading branch information
djyde and Innei authored Sep 11, 2024
1 parent 9125a49 commit 53c1c66
Show file tree
Hide file tree
Showing 28 changed files with 585 additions and 182 deletions.
44 changes: 32 additions & 12 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
},
"editor.defaultFormatter": "esbenp.prettier-vscode"
},

"tailwindCSS.experimental.classRegex": [
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
["cx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"],
// ["tw\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]

["tw`([^`]*)`", "([^`]*)"]
],

// If you do not want to autofix some rules on save
// You can put this in your user settings or workspace settings
"eslint.codeActionsOnSave.rules": [
Expand All @@ -25,20 +22,43 @@
"!arrow-body-style",
"*"
],

// If you want to silent stylistic rules
// You can put this in your user settings or workspace settings
"eslint.rules.customizations": [
{ "rule": "@stylistic/*", "severity": "off", "fixable": true },
{ "rule": "tailwindcss/classnames-order", "severity": "off" },
{ "rule": "antfu/consistent-list-newline", "severity": "off" },
{ "rule": "hyoban/jsx-attribute-spacing", "severity": "off" },
{ "rule": "simple-import-sort/*", "severity": "off" },
{ "rule": "prefer-const", "severity": "off" },
{ "rule": "unused-imports/no-unused-imports", "severity": "off" }
{
"rule": "@stylistic/*",
"severity": "off",
"fixable": true
},
{
"rule": "tailwindcss/classnames-order",
"severity": "off"
},
{
"rule": "antfu/consistent-list-newline",
"severity": "off"
},
{
"rule": "hyoban/jsx-attribute-spacing",
"severity": "off"
},
{
"rule": "simple-import-sort/*",
"severity": "off"
},
{
"rule": "prefer-const",
"severity": "off"
},
{
"rule": "unused-imports/no-unused-imports",
"severity": "off"
}
],
"cSpell.words": ["rsshub"],
"editor.foldingImportsByDefault": true,
"commentTranslate.hover.enabled": false,
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"i18n-ally.localesPaths": ["locales"],
"i18n-ally.keystyle": "nested"
}
97 changes: 97 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"words": {
"search": "Search",
"import": "Import",
"discover": "Discover",
"language": "Language"
},
"signin": {
"continue_with_github": "Continue with GitHub",
"continue_with_google": "Continue with Google",
"sign_in_to": "Sign in to"
},
"settings": {
"general": {
"app": "App",
"launch_at_login": "Launch at login",
"timeline": "Timeline",
"show_unread_on_launch": {
"description": "Show unread content on launch",
"label": "Show unread content on launch"
},
"rebuild_database": {
"warning": {
"line1": "Rebuilding the database will clear all your local data.",
"line2": "Are you sure you want to continue?"
},
"label": "Rebuild Database",
"description": "If you are experiencing rendering issues, rebuilding the database may solve them.",
"button": "Rebuild",
"title": "Rebuild Database"
},
"group_by_date": {
"label": "Group by date",
"description": "Group entries by date."
},
"mark_as_read": {
"scroll": {
"label": "Mark as read when scrolling",
"description": "Automatically mark entries as read when scrolled out of the view."
},
"hover": {
"label": "Mark as read when hovering",
"description": "Automatically mark entries as read when hovered."
},
"render": {
"label": "Mark as read when in the view",
"description": "Automatically mark single-level entries (e.g. social media posts, pictures, video views) as read when they enter the view."
}
},
"privacy_data": "Privacy & Data",
"data_persist": {
"label": "Persist data for offline usage",
"description": "Persist data locally to enable offline access and local search."
},
"send_anonymous_data": {
"label": "Send anonymous data",
"description": "By opting to send anonymized telemetry data, you contribute to improving the overall user experience of Follow."
},
"voices": "Voices"
},
"integration": {
"title": "Integration",
"eagle": {
"title": "Eagle",
"enable": {
"label": "Enable",
"description": "Display 'Save media to Eagle' button when available."
}
},
"readwise": {
"title": "Readwise",
"enable": {
"label": "Enable",
"description": "Display 'Save to Readwise' button when available."
},
"token": {
"label": "Readwise Access Token",
"description": "You can get it here: readwise.io/access_token."
}
},
"instapaper": {
"title": "Instapaper",
"enable": {
"label": "Enable",
"description": "Display 'Save to Instapaper' button when available."
},
"username": {
"label": "Instapaper Username"
},
"password": {
"label": "Instapaper Password"
}
},
"tip": "Tip: Your sensitive data is stored locally and is not uploaded to the server."
}
}
}
3 changes: 3 additions & 0 deletions locales/modules/lang/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "English"
}
3 changes: 3 additions & 0 deletions locales/modules/lang/zh_CN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "简体中文(部分完成)"
}
64 changes: 64 additions & 0 deletions locales/zh_CN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"words": {
"search": "搜索",
"import": "导入",
"discover": "发现",
"language": "语言"
},
"signin": {
"continue_with_github": "使用 GitHub 登录",
"continue_with_google": "使用 Google 登录",
"sign_in_to": "登录到"
},
"settings": {
"general": {
"app": "应用程序",
"data_persist": {
"description": "在本地保留数据以启用离线访问和本地搜索。",
"label": "保留数据以供离线使用"
},
"group_by_date": {
"description": "按日期对条目进行分组。",
"label": "按日期分组"
},
"launch_at_login": "登录时启动",
"mark_as_read": {
"hover": {
"description": "悬停时自动将条目标记为已读。",
"label": "悬停时标记为已读"
},
"render": {
"description": "当单级条目(例如社交媒体帖子、图片、视频视图)进入视图时自动将其标记为已读。",
"label": "在视图中标记为已读"
},
"scroll": {
"description": "当滚动出视图时自动将条目标记为已读。",
"label": "滚动时标记为已读"
}
},
"privacy_data": "隐私",
"rebuild_database": {
"button": "重建",
"description": "如果您遇到渲染问题,重建数据库可能会解决这些问题。",
"label": "重建数据库",
"title": "重建数据库",
"warning[0]": "重建数据库将清除所有本地数据。",
"warning[1]": "您确定要继续吗?",
"warning": {
"line1": "重建数据库将清除所有本地数据。",
"line2": "您确定要继续吗?"
}
},
"send_anonymous_data": {
"description": "通过选择发送匿名遥测数据,您可以为改善“关注”的整体用户体验做出贡献。",
"label": "发送匿名数据"
},
"show_unread_on_launch": {
"description": "启动时显示未读内容",
"label": "启动时显示未读内容"
},
"timeline": "时间轴",
"voices": "声音"
}
}
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"fuse.js": "7.0.0",
"hast-util-to-jsx-runtime": "2.3.0",
"hast-util-to-text": "4.0.2",
"i18next": "^23.15.1",
"idb-keyval": "6.2.1",
"immer": "10.1.1",
"jotai": "2.9.3",
Expand All @@ -112,6 +113,7 @@
"react-fast-marquee": "1.6.5",
"react-hook-form": "7.53.0",
"react-hotkeys-hook": "4.5.1",
"react-i18next": "^15.0.1",
"react-intersection-observer": "9.13.1",
"react-resizable-layout": "npm:@innei/react-resizable-layout@0.7.3-fork.1",
"react-router-dom": "6.26.1",
Expand Down
48 changes: 48 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/renderer/src/@types/i18next.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type resources from "./resources"

declare module "i18next" {
interface CustomTypeOptions {
resources: (typeof resources)["en"]
defaultNS: "translation"
// if you see an error like: "Argument of type 'DefaultTFuncReturn' is not assignable to parameter of type xyz"
// set returnNull to false (and also in the i18next init options)
// returnNull: false;
}
}
Loading

0 comments on commit 53c1c66

Please sign in to comment.