Improve the i18n configuration of the chat page (#719)

This commit is contained in:
徒言
2024-01-10 15:18:55 +08:00
committed by GitHub
parent dfa6586e5e
commit 414b693303
7 changed files with 41 additions and 15 deletions

View File

@@ -75,12 +75,19 @@
"Mark Description": "The annotation feature is currently in beta. \n\n After clicking Add annotation, you need to select a knowledge base in order to store annotation data. You can use this feature to quickly annotate questions and expected answers to guide the model to the next answer. At present, the annotation function, like other data in the knowledge base, is affected by the model, which does not mean that the annotation meets 100% expectations. The \n\n annotation data is only unidirectional synchronization with the knowledge base. If the knowledge base modifies the annotation data, the annotation data displayed in the log cannot be synchronized",
"Mark Description Title": "Mark Description",
"New Chat": "New Chat",
"Fresh Chat": "New Chat",
"Question Guide Tips": "I guess what you're asking is",
"Quote": "Quote",
"Pin": "Pin",
"Unpin": "Unpin",
"Read Mark Description": "Read mark description",
"Select Mark Kb": "Select Dataset",
"Select Mark Kb Desc": "Select a dataset to store the expected answers",
"You need to a chat app": "You need to a chat app",
"Failed to initialize chat": "Failed to initialize chat",
"Custom History Title": "Custom history title",
"Custom History Title Description": "If set to empty, chat history will be followed automatically.",
"History Amount": "{{amount}} records",
"logs": {
"api": "API",
"online": "Online Chat",

View File

@@ -75,12 +75,19 @@
"Mark Description": "当前标注功能为测试版。\n\n点击添加标注后需要选择一个知识库以便存储标注数据。你可以通过该功能快速的标注问题和预期回答以便引导模型下次的回答。\n\n目前标注功能同知识库其他数据一样受模型的影响不代表标注后 100% 符合预期。\n\n标注数据仅单向与知识库同步如果知识库修改了该标注数据日志展示的标注数据无法同步",
"Mark Description Title": "标注功能介绍",
"New Chat": "新对话",
"Fresh Chat": "新的对话",
"Question Guide Tips": "猜你想问",
"Quote": "引用",
"Pin": "置顶",
"Unpin": "取消置顶",
"Read Mark Description": "查看标注功能介绍",
"Select Mark Kb": "选择知识库",
"Select Mark Kb Desc": "选择一个知识库存储预期答案",
"You need to a chat app": "你需要创建一个应用",
"Failed to initialize chat": "初始化聊天失败",
"Custom History Title": "自定义历史记录标题",
"Custom History Title Description": "如果设置为空,会自动跟随聊天记录。",
"History Amount": "{{amount}}条记录",
"logs": {
"api": "API 调用",
"online": "在线使用",

View File

@@ -7,6 +7,7 @@ import Avatar from '@/components/Avatar';
import ToolMenu from './ToolMenu';
import type { ChatItemType } from '@fastgpt/global/core/chat/type';
import { useRouter } from 'next/router';
import { useTranslation } from 'next-i18next';
import { chatContentReplaceBlock } from '@fastgpt/global/core/chat/utils';
const ChatHeader = ({
@@ -28,12 +29,13 @@ const ChatHeader = ({
}) => {
const router = useRouter();
const theme = useTheme();
const { t } = useTranslation();
const { isPc } = useSystemStore();
const title = useMemo(
() =>
chatContentReplaceBlock(history[history.length - 2]?.value)?.slice(0, 8) ||
appName ||
'新对话',
t('chat.New Chat'),
[appName, history]
);
@@ -52,7 +54,11 @@ const ChatHeader = ({
</Box>
<Tag>
<MyIcon name={'history'} w={'14px'} />
<Box ml={1}>{history.length === 0 ? '新的对话' : `${history.length}条记录`}</Box>
<Box ml={1}>
{history.length === 0
? t('chat.Fresh Chat')
: t('chat.History Amount', { amount: history.length })}
</Box>
</Tag>
{!!chatModels && chatModels.length > 0 && (
<Tag ml={2} colorSchema={'green'}>

View File

@@ -74,8 +74,8 @@ const ChatHistorySlider = ({
// custom title edit
const { onOpenModal, EditModal: EditTitleModal } = useEditTitle({
title: '自定义历史记录标题',
placeholder: '如果设置为空,会自动跟随聊天记录。'
title: t('chat.Custom History Title'),
placeholder: t('chat.Custom History Title Description')
});
const { openConfirm, ConfirmModal } = useConfirm({
content: isShare
@@ -240,7 +240,7 @@ const ChatHistorySlider = ({
}}
>
<MyIcon mr={2} name={'core/chat/setTopLight'} w={'16px'}></MyIcon>
{item.top ? '取消置顶' : '置顶'}
{item.top ? t('chat.Unpin') : t('chat.Pin')}
</MenuItem>
)}
{onSetCustomTitle && (
@@ -272,7 +272,7 @@ const ChatHistorySlider = ({
}}
>
<MyIcon mr={2} name={'delete'} w={'16px'}></MyIcon>
{t('common.Delete')}
</MenuItem>
</MenuList>
</Menu>

View File

@@ -2,10 +2,12 @@ import React, { useMemo } from 'react';
import { useChatBox } from '@/components/ChatBox';
import type { ChatItemType } from '@fastgpt/global/core/chat/type.d';
import { Menu, MenuButton, MenuList, MenuItem, Box } from '@chakra-ui/react';
import { useTranslation } from 'next-i18next';
import MyIcon from '@fastgpt/web/components/common/Icon';
import { useRouter } from 'next/router';
const ToolMenu = ({ history }: { history: ChatItemType[] }) => {
const { t } = useTranslation();
const { onExportChat } = useChatBox();
const router = useRouter();
@@ -13,7 +15,7 @@ const ToolMenu = ({ history }: { history: ChatItemType[] }) => {
() => [
{
icon: 'core/chat/chatLight',
label: '新对话',
label: t('chat.New Chat'),
onClick: () => {
router.replace({
query: {
@@ -25,15 +27,19 @@ const ToolMenu = ({ history }: { history: ChatItemType[] }) => {
},
{
icon: 'core/app/appApiLight',
label: 'HTML导出',
label: `HTML ${t('Export')}`,
onClick: () => onExportChat({ type: 'html', history })
},
{
icon: 'file/markdown',
label: 'Markdown导出',
label: `Markdown ${t('Export')}`,
onClick: () => onExportChat({ type: 'md', history })
},
{ icon: 'file/pdf', label: 'PDF导出', onClick: () => onExportChat({ type: 'pdf', history }) }
{
icon: 'file/pdf',
label: `PDF ${t('Export')}`,
onClick: () => onExportChat({ type: 'pdf', history })
}
],
[history, onExportChat, router]
);

View File

@@ -86,7 +86,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
const newTitle =
chatContentReplaceBlock(prompts[0].content).slice(0, 20) ||
prompts[1]?.value?.slice(0, 20) ||
'新对话';
t('chat.New Chat');
// new chat
if (completionChatId !== chatId) {
@@ -166,7 +166,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
setLastChatAppId('');
setLastChatId('');
toast({
title: getErrText(e, '初始化聊天失败'),
title: getErrText(e, t('chat.Failed to initialize chat')),
status: 'error'
});
if (e?.code === 501) {

View File

@@ -88,7 +88,7 @@ const OutLink = ({
const newTitle =
chatContentReplaceBlock(prompts[0].content).slice(0, 20) ||
prompts[1]?.value?.slice(0, 20) ||
'新对话';
t('chat.New Chat');
// new chat
if (completionChatId !== chatId) {