Skip to content

Commit 5ab0b99

Browse files
committed
feat: Internationalization User Interface Support. PR Welcome! (#89, #39)
1 parent f5e13a3 commit 5ab0b99

File tree

22 files changed

+541
-78
lines changed

22 files changed

+541
-78
lines changed

build.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ async function runWebpack(isWithoutKatex, isWithoutTiktoken, callback) {
3838
'@primer/octicons-react',
3939
'react-bootstrap-icons',
4040
'countries-list',
41+
'i18next',
42+
'react-i18next',
4143
'./src/utils',
44+
'./src/_locales/i18n',
4245
],
4346
},
4447
output: {

package-lock.json

Lines changed: 48 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"file-saver": "^2.0.5",
2929
"github-markdown-css": "^5.2.0",
3030
"gpt-3-encoder": "^1.1.4",
31+
"i18next": "^22.4.13",
3132
"katex": "^0.16.4",
3233
"lodash-es": "^4.17.21",
3334
"parse5": "^6.0.1",
@@ -37,6 +38,7 @@
3738
"react-bootstrap-icons": "^1.10.2",
3839
"react-dom": "npm:@preact/compat@^17.1.2",
3940
"react-draggable": "^4.4.5",
41+
"react-i18next": "^12.2.0",
4042
"react-markdown": "^8.0.5",
4143
"react-tabs": "^4.2.1",
4244
"rehype-highlight": "^6.0.0",

src/_locales/en/main.json

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"General": "General",
3+
"Selection Tools": "Selection Tools",
4+
"Sites": "Sites",
5+
"Advanced": "Advanced",
6+
"Donate": "Donate",
7+
"Triggers": "Triggers",
8+
"Theme": "Theme",
9+
"API Mode": "API Mode",
10+
"Get": "Get",
11+
"Balance": "Balance",
12+
"Preferred Language": "Preferred Language",
13+
"Insert ChatGPT at the top of search results": "Insert ChatGPT at the top of search results",
14+
"Lock scrollbar while answering": "Lock scrollbar while answering",
15+
"Current Version": "Current Version",
16+
"Latest": "Latest",
17+
"Help | Changelog ": "Help | Changelog ",
18+
"Custom ChatGPT Web API Url": "Custom ChatGPT Web API Url",
19+
"Custom ChatGPT Web API Path": "Custom ChatGPT Web API Path",
20+
"Custom OpenAI API Url": "Custom OpenAI API Url",
21+
"Custom Site Regex:": "Custom Site Regex:",
22+
"Exclusively use Custom Site Regex for website matching,": "Exclusively use Custom Site Regex for website matching,",
23+
"ignoring built-in rules": "ignoring built-in rules",
24+
"Input Query:": "Input Query:",
25+
"Append Query:": "Append Query:",
26+
"Prepend Query:": "Prepend Query:",
27+
"Wechat Pay": "Wechat Pay",
28+
"Type your question here\nEnter to send, shift + enter to break line": "Type your question here\nEnter to send, shift + enter to break line",
29+
"Wait for the answer to finish and then continue here": "Wait for the answer to finish and then continue here",
30+
"Ask ChatGPT": "Ask ChatGPT",
31+
"No Input Found": "No Input Found",
32+
"You:": "You:",
33+
"Collapse": "Collapse",
34+
"Expand": "Expand",
35+
"Stop": "Stop",
36+
"Continue on official website": "Continue on official website",
37+
"Error:": "Error:",
38+
"Copy": "Copy",
39+
"Question:": "Question:",
40+
"Answer:": "Answer:",
41+
"Waiting for response...": "Waiting for response...",
42+
"Close the Window": "Close the Window",
43+
"Pin the Window": "Pin the Window",
44+
"Float the Window": "Float the Window",
45+
"Save Conversation": "Save Conversation",
46+
"UNAUTHORIZED": "UNAUTHORIZED",
47+
"Please login at https://chat.openai.com first": "Please login at https://chat.openai.com first",
48+
"Then open https://chat.openai.com/api/auth/session": "Then open https://chat.openai.com/api/auth/session",
49+
"And refresh this page or type you question again": "And refresh this page or type you question again",
50+
"Consider creating an api key at https://platform.openai.com/account/api-keys": "Consider creating an api key at https://platform.openai.com/account/api-keys",
51+
"OpenAI Security Check Required": "OpenAI Security Check Required",
52+
"Please open https://chat.openai.com/api/auth/session": "Please open https://chat.openai.com/api/auth/session",
53+
"Please open https://chat.openai.com": "Please open https://chat.openai.com",
54+
"New Chat": "New Chat",
55+
"Summarize Page": "Summarize Page",
56+
"Translate": "Translate",
57+
"Translate (Bidirectional)": "Translate (Bidirectional)",
58+
"Summary": "Summary",
59+
"Polish": "Polish",
60+
"Sentiment Analysis": "Sentiment Analysis",
61+
"Divide Paragraphs": "Divide Paragraphs",
62+
"Code Explain": "Code Explain",
63+
"Ask": "Ask",
64+
"Always": "Always",
65+
"Manually": "Manually",
66+
"When query ends with question mark (?)": "When query ends with question mark (?)",
67+
"Light": "Light",
68+
"Dark": "Dark",
69+
"Auto": "Auto",
70+
"ChatGPT (Web)": "ChatGPT (Web)",
71+
"ChatGPT (Web, GPT-4)": "ChatGPT (Web, GPT-4)",
72+
"Bing (Web, GPT-4)": "Bing (Web, GPT-4)",
73+
"ChatGPT (GPT-3.5-turbo)": "ChatGPT (GPT-3.5-turbo)",
74+
"ChatGPT (GPT-4-8k)": "ChatGPT (GPT-4-8k)",
75+
"ChatGPT (GPT-4-32k)": "ChatGPT (GPT-4-32k)",
76+
"GPT-3.5": "GPT-3.5",
77+
"Custom Model": "Custom Model",
78+
"Balanced": "Balanced",
79+
"Creative": "Creative",
80+
"Precise": "Precise",
81+
"Fast": "Fast",
82+
"API Key": "API Key",
83+
"Model Name": "Model Name",
84+
"Custom Model API Url": "Custom Model API Url",
85+
"Loading...": "Loading...",
86+
"Feedback": "Feedback"
87+
}

src/_locales/i18n.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import i18n from 'i18next'
2+
import { initReactI18next } from 'react-i18next'
3+
import { resources } from './resources'
4+
5+
i18n.use(initReactI18next).init({
6+
resources,
7+
fallbackLng: 'en',
8+
interpolation: {
9+
escapeValue: false, // not needed for react as it escapes by default
10+
},
11+
})

src/_locales/resources.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import en from './en/main.json'
2+
import zhHans from './zh-hans/main.json'
3+
import zhHant from './zh-hant/main.json'
4+
5+
export const resources = {
6+
en: {
7+
translation: en,
8+
},
9+
zh: {
10+
translation: zhHans,
11+
},
12+
zhHant: {
13+
translation: zhHant,
14+
},
15+
}

src/_locales/zh-hans/main.json

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"General": "常规",
3+
"Selection Tools": "选择浮动工具",
4+
"Sites": "站点适配",
5+
"Advanced": "高级",
6+
"Donate": "打赏",
7+
"Triggers": "触发方式",
8+
"Theme": "主题",
9+
"API Mode": "API模式",
10+
"Get": "获取",
11+
"Balance": "余额",
12+
"Preferred Language": "语言偏好",
13+
"Insert ChatGPT at the top of search results": "将对话卡片插入到搜索结果顶部",
14+
"Lock scrollbar while answering": "回答时锁定滚动条",
15+
"Current Version": "当前版本",
16+
"Latest": "最新",
17+
"Help | Changelog ": "帮助 | 更新日志 ",
18+
"Custom ChatGPT Web API Url": "自定义的ChatGPT网页API地址",
19+
"Custom ChatGPT Web API Path": "自定义的ChatGPT网页API路径",
20+
"Custom OpenAI API Url": "自定义的OpenAI API地址",
21+
"Custom Site Regex:": "自定义站点正则匹配:",
22+
"Exclusively use Custom Site Regex for website matching,": "只使用自定义站点正则匹配,",
23+
"ignoring built-in rules": "忽略内置站点规则",
24+
"Input Query:": "输入的查询选择器:",
25+
"Append Query:": "挂载到末尾的查询选择器:",
26+
"Prepend Query:": "插入到开头的查询选择器:",
27+
"Wechat Pay": "微信打赏",
28+
"Type your question here\nEnter to send, shift + enter to break line": "在此输入你的问题\n回车 发送, shift+回车 换行",
29+
"Wait for the answer to finish and then continue here": "等待回答完成, 然后在此继续",
30+
"Ask ChatGPT": "询问ChatGPT",
31+
"No Input Found": "无输入",
32+
"You:": "你:",
33+
"Collapse": "折叠",
34+
"Expand": "展开",
35+
"Stop": "停止",
36+
"Continue on official website": "在官网继续",
37+
"Error:": "错误:",
38+
"Copy": "复制",
39+
"Question:": "问题:",
40+
"Answer:": "回答:",
41+
"Waiting for response...": "等待响应...",
42+
"Close the Window": "关闭窗口",
43+
"Pin the Window": "固定窗口",
44+
"Float the Window": "浮出/分裂窗口",
45+
"Save Conversation": "保存对话",
46+
"UNAUTHORIZED": "未授权",
47+
"Please login at https://chat.openai.com first": "请先登录 https://chat.openai.com",
48+
"Then open https://chat.openai.com/api/auth/session": "然后打开 https://chat.openai.com/api/auth/session",
49+
"And refresh this page or type you question again": "之后刷新页面或重新输入你的问题",
50+
"Consider creating an api key at https://platform.openai.com/account/api-keys": "考虑在 https://platform.openai.com/account/api-keys 创建一个API Key",
51+
"OpenAI Security Check Required": "需要通过OpenAI的安全检查",
52+
"Please open https://chat.openai.com/api/auth/session": "请打开 https://chat.openai.com/api/auth/session",
53+
"Please open https://chat.openai.com": "请打开 https://chat.openai.com",
54+
"New Chat": "新建聊天",
55+
"Summarize Page": "总结本页",
56+
"Translate": "翻译",
57+
"Translate (Bidirectional)": "双向翻译",
58+
"Summary": "总结",
59+
"Polish": "润色",
60+
"Sentiment Analysis": "情感分析",
61+
"Divide Paragraphs": "段落划分",
62+
"Code Explain": "代码解释",
63+
"Ask": "询问",
64+
"Always": "自动触发",
65+
"Manually": "手动触发",
66+
"When query ends with question mark (?)": "问题以问号结尾时触发",
67+
"Light": "浅色",
68+
"Dark": "深色",
69+
"Auto": "自动",
70+
"ChatGPT (Web)": "ChatGPT (网页版)",
71+
"ChatGPT (Web, GPT-4)": "ChatGPT (网页版, GPT-4)",
72+
"Bing (Web, GPT-4)": "Bing (网页版, GPT-4)",
73+
"ChatGPT (GPT-3.5-turbo)": "ChatGPT (GPT-3.5-turbo)",
74+
"ChatGPT (GPT-4-8k)": "ChatGPT (GPT-4-8k)",
75+
"ChatGPT (GPT-4-32k)": "ChatGPT (GPT-4-32k)",
76+
"GPT-3.5": "GPT-3.5",
77+
"Custom Model": "自定义模型",
78+
"Balanced": "平衡",
79+
"Creative": "有创造力",
80+
"Precise": "精确",
81+
"Fast": "快速",
82+
"API Key": "API Key",
83+
"Model Name": "模型名",
84+
"Custom Model API Url": "自定义模型的API地址",
85+
"Loading...": "正在读取...",
86+
"Feedback": "反馈"
87+
}

0 commit comments

Comments
 (0)