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:
ochan.kwon
2026-03-05 23:42:36 +09:00
committed by lyingbug
parent 65743da754
commit db7cef5f17
43 changed files with 2366 additions and 637 deletions
@@ -1,17 +1,17 @@
<template>
<div class="kb-parser-settings">
<div class="section-header">
<h2>解析引擎</h2>
<p class="section-description">为不同文件类型选择文档解析引擎。未配置的文件类型将使用内置解析引擎。</p>
<h2>{{ $t('kbSettings.parser.title') }}</h2>
<p class="section-description">{{ $t('kbSettings.parser.description') }}</p>
</div>
<div v-if="loading" class="loading-inline">
<t-loading size="small" />
<span>加载中...</span>
<span>{{ $t('kbSettings.parser.loading') }}</span>
</div>
<div v-else-if="fileTypeGroups.length === 0" class="empty-hint">
<p>暂无可用解析引擎,或文档解析服务未配置。</p>
<p>{{ $t('kbSettings.parser.noEngineAvailable') }}</p>
</div>
<div v-else class="settings-group">
@@ -35,7 +35,7 @@
@change="(val: string) => handleEngineChange(group.extensions, val)"
style="width: 280px;"
:status="hasAvailableEngine(group.extensions) ? 'default' : 'warning'"
placeholder="无可用引擎"
:placeholder="$t('kbSettings.parser.noEngine')"
>
<t-option
v-for="opt in getEngineOptions(group.extensions)"
@@ -45,7 +45,7 @@
:disabled="opt.disabled"
>
<t-tooltip
:content="`支持格式: ${opt.fileTypes.map(t => '.' + t).join(' ')}`"
:content="$t('kbSettings.supportedFormats') + ': ' + opt.fileTypes.map(ft => '.' + ft).join(' ')"
placement="left"
:show-arrow="false"
>
@@ -57,25 +57,25 @@
theme="primary"
variant="light"
size="small"
>默认</t-tag>
>{{ $t('kbSettings.parser.default') }}</t-tag>
<t-tag
v-if="opt.disabled"
theme="danger"
variant="light"
size="small"
>不可用</t-tag>
>{{ $t('kbSettings.parser.unavailable') }}</t-tag>
</div>
<div class="engine-option-desc">{{ opt.desc }}</div>
<div v-if="opt.disabled && opt.reason" class="engine-option-reason">
{{ opt.reason }}
<a class="go-settings" @click.stop.prevent="goToParserSettings">去设置 →</a>
<a class="go-settings" @click.stop.prevent="goToParserSettings">{{ $t('kbSettings.parser.goSettings') }}</a>
</div>
</div>
</t-tooltip>
</t-option>
</t-select>
<div v-if="!hasAvailableEngine(group.extensions)" class="no-engine-warning">
<a class="go-settings" @click.prevent="goToParserSettings">前往配置 →</a>
<a class="go-settings" @click.prevent="goToParserSettings">{{ $t('kbSettings.parser.goConfig') }}</a>
</div>
</div>
</div>
@@ -85,10 +85,13 @@
<script setup lang="ts">
import { ref, watch, computed, onMounted, onUnmounted } from 'vue'
import { useI18n } from 'vue-i18n'
import { getParserEngines, type ParserEngineInfo } from '@/api/system'
import { useUIStore } from '@/stores/ui'
import { storeToRefs } from 'pinia'
const { t } = useI18n()
export interface ParserEngineRule {
file_types: string[]
engine: string
@@ -144,14 +147,14 @@ const fileTypeGroups = computed(() => {
const txtExts = ['txt'].filter(e => ft.has(e))
const imageExts = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff', 'webp'].filter(e => ft.has(e))
if (pdfExts.length) groups.push({ key: 'pdf', label: 'PDF 文档', icon: 'file-pdf', extensions: pdfExts })
if (officeExts.length) groups.push({ key: 'office', label: 'Word 文档', icon: 'file-word', extensions: officeExts })
if (pptExts.length) groups.push({ key: 'ppt', label: '演示文稿', icon: 'file-powerpoint', extensions: pptExts })
if (excelExts.length) groups.push({ key: 'excel', label: 'Excel 表格', icon: 'file-excel', extensions: excelExts })
if (csvExts.length) groups.push({ key: 'csv', label: 'CSV 文件', icon: 'file-excel', extensions: csvExts })
if (pdfExts.length) groups.push({ key: 'pdf', label: t('kbSettings.parser.fileTypePdf'), icon: 'file-pdf', extensions: pdfExts })
if (officeExts.length) groups.push({ key: 'office', label: t('kbSettings.parser.fileTypeWord'), icon: 'file-word', extensions: officeExts })
if (pptExts.length) groups.push({ key: 'ppt', label: t('kbSettings.parser.fileTypePpt'), icon: 'file-powerpoint', extensions: pptExts })
if (excelExts.length) groups.push({ key: 'excel', label: t('kbSettings.parser.fileTypeExcel'), icon: 'file-excel', extensions: excelExts })
if (csvExts.length) groups.push({ key: 'csv', label: t('kbSettings.parser.fileTypeCsv'), icon: 'file-excel', extensions: csvExts })
if (mdExts.length) groups.push({ key: 'markdown', label: 'Markdown', icon: 'file-code', extensions: mdExts })
if (txtExts.length) groups.push({ key: 'text', label: '纯文本', icon: 'file', extensions: txtExts })
if (imageExts.length) groups.push({ key: 'image', label: '图片', icon: 'image', extensions: imageExts })
if (txtExts.length) groups.push({ key: 'text', label: t('kbSettings.parser.fileTypeText'), icon: 'file', extensions: txtExts })
if (imageExts.length) groups.push({ key: 'image', label: t('kbSettings.parser.fileTypeImage'), icon: 'image', extensions: imageExts })
return groups
})
@@ -1,28 +1,28 @@
<template>
<div class="kb-storage-settings">
<div class="section-header">
<h2>存储引擎</h2>
<h2>{{ $t('kbSettings.storage.title') }}</h2>
<p class="section-description">
选择文件存储引擎,影响文档上传存储和文档中图片的存储方式。参数在全局设置中配置。
{{ $t('kbSettings.storage.description') }}
</p>
</div>
<div v-if="loading" class="loading-inline">
<t-loading size="small" />
<span>加载中...</span>
<span>{{ $t('kbSettings.storage.loading') }}</span>
</div>
<div v-else class="settings-group">
<div class="setting-row">
<div class="setting-info">
<label>存储引擎</label>
<p class="desc">选择该知识库使用的存储引擎,需在全局设置中已配置对应引擎。</p>
<label>{{ $t('kbSettings.storage.engineLabel') }}</label>
<p class="desc">{{ $t('kbSettings.storage.engineDesc') }}</p>
</div>
<div class="setting-control">
<t-select
v-model="localProvider"
size="medium"
placeholder="请选择存储引擎"
:placeholder="$t('kbSettings.storage.selectPlaceholder')"
style="width: 100%; min-width: 220px;"
:disabled="props.hasFiles"
@change="handleChange"
@@ -36,14 +36,14 @@
>
<span class="select-option">
<span>{{ opt.label }}</span>
<t-tag v-if="opt.disabled" theme="warning" variant="light" size="small">未配置</t-tag>
<t-tag v-else-if="opt.available === false" theme="danger" variant="light" size="small">不可用</t-tag>
<t-tag v-if="opt.disabled" theme="warning" variant="light" size="small">{{ $t('kbSettings.storage.notConfigured') }}</t-tag>
<t-tag v-else-if="opt.available === false" theme="danger" variant="light" size="small">{{ $t('kbSettings.storage.unavailable') }}</t-tag>
</span>
</t-option>
</t-select>
<p v-if="props.hasFiles" class="option-hint locked-hint">知识库中已有文件,无法切换存储引擎。如需更换,请先清空知识库中的所有文件。</p>
<p v-if="props.hasFiles" class="option-hint locked-hint">{{ $t('kbSettings.storage.lockedHint') }}</p>
<p v-else-if="selectedOption?.desc" class="option-hint">{{ selectedOption.desc }}</p>
<a v-if="showGoSettings" href="javascript:void(0)" class="go-settings" @click.prevent="goToStorageSettings">去全局设置中配置</a>
<a v-if="showGoSettings" href="javascript:void(0)" class="go-settings" @click.prevent="goToStorageSettings">{{ $t('kbSettings.storage.goGlobalSettings') }}</a>
</div>
</div>
</div>
@@ -52,9 +52,12 @@
<script setup lang="ts">
import { ref, computed, watch, onMounted } from 'vue'
import { useI18n } from 'vue-i18n'
import { getStorageEngineConfig, getStorageEngineStatus, type StorageEngineStatusItem } from '@/api/system'
import { useUIStore } from '@/stores/ui'
const { t } = useI18n()
const props = defineProps<{
storageProvider: string
hasFiles?: boolean
@@ -79,29 +82,29 @@ const engineOptions = computed(() => {
return [
{
value: 'local',
label: 'Local(本地存储)',
desc: '仅适合单机部署,简单轻量',
label: t('kbSettings.storage.engineLocal'),
desc: t('kbSettings.storage.engineLocalDesc'),
available: statusMap.local !== false,
disabled: false,
},
{
value: 'minio',
label: 'MinIO',
desc: 'S3 兼容,适合内网或私有云',
desc: t('kbSettings.storage.engineMinioDesc'),
available: statusMap.minio,
disabled: statusMap.minio === false,
},
{
value: 'cos',
label: '腾讯云 COS',
desc: '公有云部署,支持 CDN 加速',
label: t('kbSettings.storage.engineCos'),
desc: t('kbSettings.storage.engineCosDesc'),
available: statusMap.cos,
disabled: statusMap.cos === false,
},
{
value: 'tos',
label: '火山引擎 TOS',
desc: '火山引擎对象存储,适合公有云部署',
label: t('kbSettings.storage.engineTos'),
desc: t('kbSettings.storage.engineTosDesc'),
available: statusMap.tos,
disabled: statusMap.tos === false,
},