@@ -924,25 +935,34 @@ export default (props: {}) => {
setTotalCost(getTotalCost());
}}
>
- Reset Total Cost
+
Reset Total Cost
-
+
-
+
diff --git a/src/translate/index.tsx b/src/translate/index.tsx
index b6af9f1..654578a 100644
--- a/src/translate/index.tsx
+++ b/src/translate/index.tsx
@@ -1,4 +1,4 @@
-import { createContext } from "react";
+import { createContext, useContext } from "react";
import MAP_zh_CN from "@/translate/zh_CN";
interface LangOption {
@@ -20,7 +20,26 @@ const LANG_OPTIONS: Record
= {
},
};
-const langCodeContext = createContext("en-US");
+// lowercase all langMap keys
+Object.keys(LANG_OPTIONS).forEach((langCode) => {
+ const langMap = LANG_OPTIONS[langCode].langMap;
+ const newLangMap: Record = {};
+ Object.keys(langMap).forEach((key) => {
+ newLangMap[key.toLowerCase()] = langMap[key];
+ });
+ LANG_OPTIONS[langCode].langMap = newLangMap;
+});
+
+type LangCode = "en-US" | "zh-CN";
+
+interface LangCodeContextSchema {
+ langCode: LangCode;
+ setLangCode: (langCode: LangCode) => void;
+}
+const langCodeContext = createContext({
+ langCode: "en-US",
+ setLangCode: () => {},
+});
function tr(text: string, langCode: "en-US" | "zh-CN") {
const option = LANG_OPTIONS[langCode];
@@ -31,18 +50,18 @@ function tr(text: string, langCode: "en-US" | "zh-CN") {
const translatedText = langMap[text.toLowerCase()];
if (translatedText === undefined) {
+ console.log(`[Translation] not found for "${text}"`);
return text;
}
return translatedText;
}
-
-function Tr(text: string) {
+function Tr({ children }: { children: string }) {
return (
{/* @ts-ignore */}
{({ langCode }) => {
- return tr(text, langCode);
+ return tr(children, langCode);
}}
);
diff --git a/src/translate/zh_CN.ts b/src/translate/zh_CN.ts
index edf60cd..a1ac7d7 100644
--- a/src/translate/zh_CN.ts
+++ b/src/translate/zh_CN.ts
@@ -62,6 +62,85 @@ const LANG_MAP: Record = {
example: "示例",
render: "渲染",
"reset current": "清空当前会话",
+ "send message": "发送",
+ "type your message here...": "在此输入消息...",
+ "total tokens": "总token数",
+ "session cost": "本会话消费",
+ "accumulated cost": "累计消费",
+ session: "会话",
+ "you can customize all the settings here": "您可以在此处自定义所有设置",
+ "Image Gen API": "图片生成 API",
+ "Image generation API endpoint. Service is enabled when this is set. Default: https://api.openai.com/v1/images/generations":
+ "图片生成 API 端点。设置后服务将启用。默认: https://api.openai.com/v1/images/generations",
+ "Image generation service API key. Defaults to the OpenAI key above, but can be configured separately here":
+ "图片生成服务 API 密钥。默认为上面的 OpenAI 密钥,但可以在此处单独配置",
+ "Adjust the playback speed of text-to-speech": "调整文本转语音的播放速度",
+ "TTS API endpoint. Service is enabled when this is set. Default: https://api.openai.com/v1/audio/speech":
+ "TTS API 端点。设置后服务将启用。默认: https://api.openai.com/v1/audio/speech",
+ "Text-to-speech service API key. Defaults to the OpenAI key above, but can be configured separately here":
+ "文本转语音服务 API 密钥。默认为上面的 OpenAI 密钥,但可以在此处单独配置",
+ "Whisper speech-to-text service. Service is enabled when this is set. Default: https://api.openai.com/v1/audio/transriptions":
+ "Whisper 语音转文本服务。设置后服务将启用。默认: https://api.openai.com/v1/audio/transriptions",
+ "Used for Whisper service. Defaults to the OpenAI key above, but can be configured separately here":
+ "用于 Whisper 服务。默认为上面的 OpenAI 密钥,但可以在此处单独配置",
+ "Frequency Penalty": "频率惩罚",
+ "Presence Penalty": "存在惩罚",
+ "Top P sampling method. It is recommended to choose one of the temperature sampling methods, do not enable both at the same time.":
+ "Top P 采样方法。建议选择其中一种温度采样方法,不要同时启用两种。",
+ "Total token count, this parameter will be updated every time you chat, in stream mode this parameter is an estimate":
+ "总 token 数,此参数将在每次对话时更新,在流式模式下此参数是一个估计",
+ "Indicates how many history messages to 'forget' when sending API requests":
+ "发送 API 请求时遗忘多少历史消息",
+ 'When totalTokens > maxTokens - tokenMargin, the history message will be truncated, chatgpt will "forget" part of the messages in the conversation (but all history messages are still saved locally)':
+ "当 totalTokens > maxTokens - tokenMargin 时,历史消息将被截断,chatgpt 将“遗忘”对话中的部分消息(但所有历史消息仍然在本地保存)",
+ "maxGenTokens is the maximum number of tokens that can be generated in a scingle request.":
+ "maxGenTokens 是一次请求中可以生成的最大 token 数。",
+ "Logprobs, return the probability of each token":
+ "Logprobs,返回每个 token 的概率",
+ "Stream Mode, use stream mode to see the generated content dynamically, but the token count cannot be accurately calculated, which may cause too much or too little history messages to be truncated when the token count is too large.":
+ "流式模式,使用流式模式动态查看生成的内容,但无法准确计算 token 数,当 token 数过大时可能导致截断过多或过少的历史消息。",
+ "Temperature, the higher the value, the higher the randomness of the generated text.":
+ "温度,值越高,生成文本的随机性越高。",
+ "Model, Different models have different performance and pricing, please refer to the API documentation":
+ "模型,不同的模型具有不同的性能和定价,请参考 API 文档",
+ "Chat API": "对话 API",
+ "API endpoint, useful for using reverse proxy services in unsupported regions, default to https://api.openai.com/v1/chat/completions":
+ "API 端点,用于在不受支持的地区使用反向代理服务,默认为 https://api.openai.com/v1/chat/completions",
+ "OpenAI API key, do not leak this key": "OpenAI API 密钥,请勿泄漏",
+ "Select language": "选择语言",
+ "Develop Mode, enable to show more options and features":
+ "开发者模式,启用以显示更多选项和功能",
+ "Saved Template": "已保存模板",
+ "Image Generation": "图片生成",
+ TTS: "文本转语音",
+ "Speech Recognition": "语音识别",
+ System: "系统",
+ "Max context token count. This value will be set automatically based on the selected model.":
+ "最大上下文 token 数。此值将根据所选模型自动设置。",
+ chat: "对话",
+ save: "保存",
+ "Configure speech recognition settings": "配置语音识别设置",
+ "Whisper API": "Whisper API",
+ Custom: "自定义",
+ "Configure the LLM API settings": "配置 LLM API 设置",
+ "TTS Voice": "TTS 语音",
+ "TTS Format": "TTS 格式",
+ Formats: "格式",
+ "TTS API": "TTS API",
+ "Configure text-to-speech settings": "配置文本转语音设置",
+ Voices: "语音",
+ "in all sessions": "所有会话",
+ "Reset Total Cost": "重置总消费",
+ Language: "语言",
+ "Quick Actions": "快速操作",
+ Import: "导入",
+ Languages: "语言",
+ "maxGenTokens is the maximum number of tokens that can be generated in a single request.":
+ "maxGenTokens 是一次请求中可以生成的最大 token 数。",
+ "Image Generation API": "图片生成 API",
+ "Configure image generation settings": "配置图片生成设置",
+ "New Chat": "新对话",
+ "Delete Chat": "删除对话",
};
export default LANG_MAP;