From 7cd170b933b4be3e85ebe689dd397e6549bbeff7 Mon Sep 17 00:00:00 2001 From: Yifei Zhang Date: Mon, 20 Mar 2023 16:17:45 +0000 Subject: [PATCH] feat: support i18n --- app/components/home.tsx | 31 ++++++++-------- app/components/settings.tsx | 61 +++++++++++++++++-------------- app/locales/cn.ts | 71 +++++++++++++++++++++++++++++++++++++ app/locales/en.ts | 70 ++++++++++++++++++++++++++++++++++++ app/locales/index.ts | 30 ++++++++++++++++ app/store.ts | 18 +++++----- app/utils.ts | 6 ++-- 7 files changed, 235 insertions(+), 52 deletions(-) create mode 100644 app/locales/cn.ts create mode 100644 app/locales/en.ts create mode 100644 app/locales/index.ts diff --git a/app/components/home.tsx b/app/components/home.tsx index 32e6b233..1db1f1ea 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -23,6 +23,7 @@ import DownloadIcon from "../icons/download.svg"; import { Message, SubmitKey, useChatStore, ChatSession } from "../store"; import { showModal } from "./ui-lib"; import { copyToClipboard, downloadAs, isIOS } from "../utils"; +import Locale from '../locales' import dynamic from "next/dynamic"; @@ -77,7 +78,7 @@ export function ChatItem(props: { >
{props.title}
-
{props.count} 条对话
+
{Locale.ChatItem.ChatItemCount(props.count)}
{props.time}
@@ -200,7 +201,7 @@ export function Chat(props: { showSideBar?: () => void }) {
{session.topic}
- 与 ChatGPT 的 {session.messages.length} 条对话 + {Locale.Chat.SubTitle(session.messages.length)}
@@ -208,7 +209,7 @@ export function Chat(props: { showSideBar?: () => void }) { } bordered - title="查看消息列表" + title={Locale.Chat.Actions.ChatList} onClick={props?.showSideBar} />
@@ -216,7 +217,7 @@ export function Chat(props: { showSideBar?: () => void }) { } bordered - title="查看压缩后的历史 Prompt" + title={Locale.Chat.Actions.CompressedHistory} onClick={() => { showMemoryPrompt(session) }} @@ -226,7 +227,7 @@ export function Chat(props: { showSideBar?: () => void }) { } bordered - title="导出聊天记录" + title={Locale.Chat.Actions.Export} onClick={() => { exportMessages(session.messages, session.topic) }} @@ -251,7 +252,7 @@ export function Chat(props: { showSideBar?: () => void }) {
{(message.preview || message.streaming) && ( -
正在输入…
+
{Locale.Chat.Typing}
)}
{(message.preview || message.content.length === 0) && @@ -283,7 +284,7 @@ export function Chat(props: { showSideBar?: () => void }) {