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
+15 -13
View File
@@ -12,10 +12,12 @@ import {
import { knowledgeStore } from "@/stores/knowledge";
import { useUIStore } from "@/stores/ui";
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
export default function (knowledgeBaseId?: string) {
const usemenuStore = knowledgeStore();
const route = useRoute();
const { t } = useI18n();
const { cardList, total } = storeToRefs(usemenuStore);
let moreIndex = ref(-1);
const details = reactive({
@@ -41,7 +43,7 @@ export default function (knowledgeBaseId?: string) {
.then((result: any) => {
const { data, total: totalResult } = result;
const cardList_ = data.map((item: any) => {
const rawName = item.file_name || item.title || item.source || '未命名文档'
const rawName = item.file_name || item.title || item.source || t('knowledgeBase.untitledDocument')
const dotIndex = rawName.lastIndexOf('.')
const displayName = dotIndex > 0 ? rawName.substring(0, dotIndex) : rawName
const fileTypeSource = item.file_type || (item.type === 'manual' ? 'MANUAL' : '')
@@ -71,7 +73,7 @@ export default function (knowledgeBaseId?: string) {
return delKnowledgeDetails(item.id)
.then((result: any) => {
if (result.success) {
MessagePlugin.info("知识删除成功!");
MessagePlugin.info(t('knowledgeBase.deleteSuccess'));
if (onSuccess) {
onSuccess();
} else {
@@ -79,12 +81,12 @@ export default function (knowledgeBaseId?: string) {
}
return true;
} else {
MessagePlugin.error("知识删除失败!");
MessagePlugin.error(t('knowledgeBase.deleteFailed'));
return false;
}
})
.catch(() => {
MessagePlugin.error("知识删除失败!");
MessagePlugin.error(t('knowledgeBase.deleteFailed'));
return false;
});
};
@@ -98,7 +100,7 @@ export default function (knowledgeBaseId?: string) {
};
const requestMethod = (file: any, uploadInput: any) => {
if (!(file instanceof File) || !uploadInput) {
MessagePlugin.error("文件类型错误!");
MessagePlugin.error(t('error.invalidFileType'));
return;
}
@@ -116,7 +118,7 @@ export default function (knowledgeBaseId?: string) {
currentKbId = knowledgeBaseId;
}
if (!currentKbId) {
MessagePlugin.error("缺少知识库ID");
MessagePlugin.error(t('error.missingKbId'));
return;
}
@@ -127,17 +129,17 @@ export default function (knowledgeBaseId?: string) {
uploadKnowledgeFile(currentKbId, { file, tag_id: tagIdToUpload })
.then((result: any) => {
if (result.success) {
MessagePlugin.info("上传成功!");
MessagePlugin.info(t('knowledgeBase.uploadSuccess'));
getKnowled({ page: 1, page_size: 35 }, currentKbId);
} else {
const errorMessage = result.error?.message || result.message || "上传失败!";
MessagePlugin.error(result.code === 'duplicate_file' ? "文件已存在" : errorMessage);
const errorMessage = result.error?.message || result.message || t('knowledgeBase.uploadFailed');
MessagePlugin.error(result.code === 'duplicate_file' ? t('knowledgeBase.fileExists') : errorMessage);
}
uploadInput.value.value = "";
})
.catch((err: any) => {
const errorMessage = err.error?.message || err.message || "上传失败!";
MessagePlugin.error(err.code === 'duplicate_file' ? "文件已存在" : errorMessage);
const errorMessage = err.error?.message || err.message || t('knowledgeBase.uploadFailed');
MessagePlugin.error(err.code === 'duplicate_file' ? t('knowledgeBase.fileExists') : errorMessage);
uploadInput.value.value = "";
});
};
@@ -157,7 +159,7 @@ export default function (knowledgeBaseId?: string) {
if (result.success && result.data) {
const { data } = result;
Object.assign(details, {
title: data.file_name || data.title || data.source || '未命名文档',
title: data.file_name || data.title || data.source || t('knowledgeBase.untitledDocument'),
time: formatStringDate(new Date(data.updated_at)),
id: data.id,
type: data.type || 'file',
@@ -186,7 +188,7 @@ export default function (knowledgeBaseId?: string) {
}
})
.catch((err: any) => {
details.chunkLoadError = err?.message || "分块加载失败";
details.chunkLoadError = err?.message || t('knowledgeBase.chunkLoadFailed');
console.error("[ChunkLoad] failed", {
knowledgeId: id,
page,