feat(i18n): replace hardcoded Chinese strings with i18n calls across frontend
Replace all user-visible hardcoded Chinese strings in Vue/TS source files
with proper i18n function calls and add corresponding translation keys
to all 4 locale files (zh-CN, en-US, ko-KR, ru-RU).
Changes:
- Replace 80+ hardcoded Chinese strings across 30+ source files
- Add ~450 new translation keys per locale file
- Cover components, views, utils, hooks, and API modules
- Remove Chinese fallback patterns (|| '中文') from existing t() calls
- Add mermaid toolbar and ollama date format translations
Intentionally preserved (backend API values / backward compatibility):
- FAQ CSV column headers and parsing constants
- RelevanceLevel type and Record key mappings
- Graph database engine status comparison ('未启用')
- Language name labels ('简体中文')
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
* Mermaid 图表全屏查看器
|
||||
* 支持:点击放大、滚轮缩放、鼠标拖拽、高清导出
|
||||
*/
|
||||
import i18n from '@/i18n';
|
||||
|
||||
/**
|
||||
* 下载 SVG 为 PNG 图片(使用实际渲染尺寸)
|
||||
@@ -54,7 +55,7 @@ const showBtnFeedback = (btn: HTMLElement, success: boolean, text?: string): voi
|
||||
const origColor = btn.style.color
|
||||
const origTitle = btn.title
|
||||
btn.style.color = success ? '#07c05f' : '#ef4444'
|
||||
btn.title = text || (success ? '成功' : '失败')
|
||||
btn.title = text || (success ? i18n.global.t('common.success') : i18n.global.t('common.failed'))
|
||||
setTimeout(() => {
|
||||
btn.style.color = origColor
|
||||
btn.title = origTitle
|
||||
@@ -93,11 +94,12 @@ export const openMermaidFullscreen = (svgHtml: string): void => {
|
||||
return btn
|
||||
}
|
||||
|
||||
const zoomInBtn = createBtn('放大', '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="11" y1="8" x2="11" y2="14"/><line x1="8" y1="11" x2="14" y2="11"/></svg>')
|
||||
const zoomOutBtn = createBtn('缩小', '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="8" y1="11" x2="14" y2="11"/></svg>')
|
||||
const resetBtn = createBtn('重置', '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>')
|
||||
const downloadBtn = createBtn('下载图片', '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>')
|
||||
const closeBtn = createBtn('关闭', '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>')
|
||||
const t = (key: string) => i18n.global.t(key);
|
||||
const zoomInBtn = createBtn(t('mermaid.zoomIn'), '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="11" y1="8" x2="11" y2="14"/><line x1="8" y1="11" x2="14" y2="11"/></svg>')
|
||||
const zoomOutBtn = createBtn(t('mermaid.zoomOut'), '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="8" y1="11" x2="14" y2="11"/></svg>')
|
||||
const resetBtn = createBtn(t('mermaid.reset'), '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>')
|
||||
const downloadBtn = createBtn(t('mermaid.download'), '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>')
|
||||
const closeBtn = createBtn(t('mermaid.close'), '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>')
|
||||
toolbar.append(zoomInBtn, zoomOutBtn, resetBtn, downloadBtn, closeBtn)
|
||||
|
||||
// 创建内容区域
|
||||
@@ -139,7 +141,7 @@ export const openMermaidFullscreen = (svgHtml: string): void => {
|
||||
e.stopPropagation()
|
||||
if (!svgEl) return
|
||||
downloadSvgAsImage(svgEl)
|
||||
showBtnFeedback(downloadBtn, true, '下载中...')
|
||||
showBtnFeedback(downloadBtn, true, t('mermaid.downloading'))
|
||||
}
|
||||
|
||||
// 关闭函数
|
||||
|
||||
Reference in New Issue
Block a user