feat: 对话语言国际化
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { memo, useEffect, useRef } from 'react';
|
import { memo, useEffect, useRef } from 'react';
|
||||||
import type { ChatMessageItem } from './types';
|
import type { ChatMessageItem } from './types';
|
||||||
|
import { useI18n } from '../../i18n';
|
||||||
|
|
||||||
type ChatMessageListProps = {
|
type ChatMessageListProps = {
|
||||||
messages: ChatMessageItem[];
|
messages: ChatMessageItem[];
|
||||||
@@ -8,6 +9,7 @@ type ChatMessageListProps = {
|
|||||||
|
|
||||||
function ChatMessageList({ messages, loading }: ChatMessageListProps) {
|
function ChatMessageList({ messages, loading }: ChatMessageListProps) {
|
||||||
const containerRef = useRef<HTMLDivElement | null>(null);
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const container = containerRef.current;
|
const container = containerRef.current;
|
||||||
@@ -20,12 +22,12 @@ function ChatMessageList({ messages, loading }: ChatMessageListProps) {
|
|||||||
<div ref={containerRef} className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pr-1">
|
<div ref={containerRef} className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pr-1">
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<div className="rounded-[18px] border border-dashed border-[#BEDBFF] bg-[#EFF6FF] px-4 py-3 text-sm text-[#525866] dark:border-[#2a2a2d] dark:bg-[#1f1f22] dark:text-gray-400">
|
<div className="rounded-[18px] border border-dashed border-[#BEDBFF] bg-[#EFF6FF] px-4 py-3 text-sm text-[#525866] dark:border-[#2a2a2d] dark:bg-[#1f1f22] dark:text-gray-400">
|
||||||
正在加载会话内容...
|
{t('conversation.messageList.loading')}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{!loading && messages.length === 0 ? (
|
{!loading && messages.length === 0 ? (
|
||||||
<div className="rounded-[18px] border border-dashed border-[#BEDBFF] bg-[#EFF6FF] px-4 py-6 text-sm leading-7 text-[#525866] dark:border-[#2a2a2d] dark:bg-[#1f1f22] dark:text-gray-400">
|
<div className="rounded-[18px] border border-dashed border-[#BEDBFF] bg-[#EFF6FF] px-4 py-6 text-sm leading-7 text-[#525866] dark:border-[#2a2a2d] dark:bg-[#1f1f22] dark:text-gray-400">
|
||||||
输入你的问题开始一段新对话,现有会话和流式响应都会直接显示在这里。
|
{t('conversation.messageList.emptyHint')}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{messages.map((message) => (
|
{messages.map((message) => (
|
||||||
@@ -81,7 +83,7 @@ function ChatMessageList({ messages, loading }: ChatMessageListProps) {
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{message.isStreaming ? (
|
{message.isStreaming ? (
|
||||||
<div className="mt-3 text-xs text-[#2B7FFF]">正在生成回复...</div>
|
<div className="mt-3 text-xs text-[#2B7FFF]">{t('conversation.messageList.streaming')}</div>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
@@ -43,6 +43,11 @@ export const messages: I18nMessages = {
|
|||||||
placeholder: 'Type a message, press Enter to send, Shift + Enter for a new line',
|
placeholder: 'Type a message, press Enter to send, Shift + Enter for a new line',
|
||||||
dismissError: 'Close',
|
dismissError: 'Close',
|
||||||
},
|
},
|
||||||
|
messageList: {
|
||||||
|
loading: 'Loading conversation...',
|
||||||
|
emptyHint: 'Start a new conversation by typing your question. Existing messages and streaming responses will appear here directly.',
|
||||||
|
streaming: 'Generating reply...',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
sidebar: {
|
sidebar: {
|
||||||
home: 'Home',
|
home: 'Home',
|
||||||
@@ -527,6 +532,11 @@ export const messages: I18nMessages = {
|
|||||||
placeholder: '输入消息,按 Enter 发送,Shift + Enter 换行',
|
placeholder: '输入消息,按 Enter 发送,Shift + Enter 换行',
|
||||||
dismissError: '关闭',
|
dismissError: '关闭',
|
||||||
},
|
},
|
||||||
|
messageList: {
|
||||||
|
loading: '正在加载会话内容...',
|
||||||
|
emptyHint: '输入你的问题开始一段新对话,现有会话和流式响应都会直接显示在这里。',
|
||||||
|
streaming: '正在生成回复...',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
sidebar: {
|
sidebar: {
|
||||||
home: '首页',
|
home: '首页',
|
||||||
@@ -1011,6 +1021,11 @@ export const messages: I18nMessages = {
|
|||||||
placeholder: 'メッセージを入力し、Enter で送信、Shift + Enter で改行',
|
placeholder: 'メッセージを入力し、Enter で送信、Shift + Enter で改行',
|
||||||
dismissError: '閉じる',
|
dismissError: '閉じる',
|
||||||
},
|
},
|
||||||
|
messageList: {
|
||||||
|
loading: '会話内容を読み込み中...',
|
||||||
|
emptyHint: '質問を入力して新しい会話を始めましょう。既存の会話とストリーミング応答はここに直接表示されます。',
|
||||||
|
streaming: '返信を生成中...',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
sidebar: {
|
sidebar: {
|
||||||
home: 'ホーム',
|
home: 'ホーム',
|
||||||
|
|||||||
Reference in New Issue
Block a user