feat: 对话语言国际化

This commit is contained in:
DEV_DSW
2026-04-21 11:46:45 +08:00
parent 0e10ae9e35
commit 5db3e5714f
2 changed files with 20 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
import { memo, useEffect, useRef } from 'react';
import type { ChatMessageItem } from './types';
import { useI18n } from '../../i18n';
type ChatMessageListProps = {
messages: ChatMessageItem[];
@@ -8,6 +9,7 @@ type ChatMessageListProps = {
function ChatMessageList({ messages, loading }: ChatMessageListProps) {
const containerRef = useRef<HTMLDivElement | null>(null);
const { t } = useI18n();
useEffect(() => {
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">
{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">
...
{t('conversation.messageList.loading')}
</div>
) : null}
{!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">
{t('conversation.messageList.emptyHint')}
</div>
) : null}
{messages.map((message) => (
@@ -81,7 +83,7 @@ function ChatMessageList({ messages, loading }: ChatMessageListProps) {
</div>
) : null}
{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}
</div>
</article>

View File

@@ -43,6 +43,11 @@ export const messages: I18nMessages = {
placeholder: 'Type a message, press Enter to send, Shift + Enter for a new line',
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: {
home: 'Home',
@@ -527,6 +532,11 @@ export const messages: I18nMessages = {
placeholder: '输入消息,按 Enter 发送Shift + Enter 换行',
dismissError: '关闭',
},
messageList: {
loading: '正在加载会话内容...',
emptyHint: '输入你的问题开始一段新对话,现有会话和流式响应都会直接显示在这里。',
streaming: '正在生成回复...',
},
},
sidebar: {
home: '首页',
@@ -1011,6 +1021,11 @@ export const messages: I18nMessages = {
placeholder: 'メッセージを入力し、Enter で送信、Shift + Enter で改行',
dismissError: '閉じる',
},
messageList: {
loading: '会話内容を読み込み中...',
emptyHint: '質問を入力して新しい会話を始めましょう。既存の会話とストリーミング応答はここに直接表示されます。',
streaming: '返信を生成中...',
},
},
sidebar: {
home: 'ホーム',