apply_cjk_translations.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. const fs = require('fs');
  2. const path = require('path');
  3. const directories = ['d:/workspace/AuraK/web', 'd:/workspace/AuraK/server/src'];
  4. const excludeDirs = ['node_modules', '.git', 'dist', '.next', 'dist-check', 'docs', 'data'];
  5. const extensions = ['.ts', '.tsx', '.js', '.jsx'];
  6. const translations = {
  7. // ChatInterface.tsx
  8. "履歴メッセージの読み込みを処理": "Handle loading of history messages",
  9. "履歴メッセージが読み込まれたことを親コンポーネントに通知": "Notify parent component that history messages have been loaded",
  10. "デバウンス機構:500ms以内の重複送信を防止": "Debounce mechanism: prevent duplicate submissions within 500ms",
  11. "入力欄を即座にクリアして高さをリセットし、重複送信を防止": "Instantly clear input field and reset height to prevent duplicate submission",
  12. "フォーカスを外す": "Remove focus",
  13. "初期ボットメッセージを追加": "Add initial bot message",
  14. "グループフィルタを渡す": "Pass group filter",
  15. "ファイルフィルタを渡す": "Pass file filter",
  16. "履歴IDを渡す": "Pass history ID",
  17. "Rerankスイッチを渡す": "Pass Rerank switch",
  18. "RerankモデルIDを渡す": "Pass Rerank model ID",
  19. "温度パラメータを渡す": "Pass temperature parameter",
  20. "最大トークン数を渡す": "Pass max tokens",
  21. "Top-Kパラメータを渡す": "Pass Top-K parameter",
  22. "類似度しきい値を渡す": "Pass similarity threshold",
  23. "Rerankしきい値を渡す": "Pass Rerank threshold",
  24. "クエリ拡張を渡す": "Pass query expansion",
  25. "HyDEを渡す": "Pass HyDE",
  26. // CreateNoteFromPDFDialog.tsx
  27. "ナレッジグループが選択されているか確認": "Check if knowledge group is selected",
  28. "使用 toast 提示用户先选择知识组": "Use toast to prompt user to select a knowledge group first",
  29. // FileGroupTags.tsx
  30. "カスタムイベントを監視してグループセレクターを開く": "Monitor custom events to open group selector",
  31. "正しい方法:すべてのグループID(既存 + 新規)を渡す": "Correct method: pass all group IDs (existing + new)",
  32. // GroupManager.tsx
  33. "分组列表": "Group list",
  34. "个文件": " files",
  35. "创建按钮": "Create button",
  36. "创建/编辑模态框": "Create/Edit modal",
  37. "颜色标识": "Color indicator",
  38. // GroupSelector.tsx
  39. "选择分组范围": "Select group scope",
  40. "全部分组": "All groups",
  41. "已选 ": "Selected ",
  42. " 个分组": " groups",
  43. "搜索分组...": "Search groups...",
  44. "未找到相关分组": "No related groups found",
  45. "暂无分组": "No groups",
  46. // IndexingModalWithMode.tsx
  47. "ユーザーによる手動選択をマーク": "Mark manual selection by user",
  48. // InputDrawer.tsx
  49. "确定": "Confirm",
  50. "取消": "Cancel",
  51. // SidebarRail.tsx
  52. "ナビゲーション項目": "Navigation items",
  53. "現在のルートに基づいてアクティブなタブを決定": "Determine active tab based on current route",
  54. // ModeSelector.tsx
  55. "処理モード選択コンポーネント": "Processing mode selection component",
  56. "ファイルアップロード時に高速モードまたは精密モードを選択するために使用": "Used to select fast or precise mode when uploading files",
  57. "推薦されたモードを自動選択": "Automatically select recommended mode",
  58. "処理モードの選択": "Select processing mode",
  59. "分析中...": "Analyzing...",
  60. "模式推荐信息": "Mode recommendation info",
  61. "推奨:": "Recommended:",
  62. "模式选择": "Mode selection",
  63. "高速モード": "Fast Mode",
  64. "テキストを単純に抽出、高速、プレーンテキストドキュメントに最適": "Simple text extraction, fast, ideal for plain text documents",
  65. "高速": "Fast",
  66. "追加コストなし": "No additional cost",
  67. "テキスト情報のみ処理": "Processes text information only",
  68. "精密モード": "Precise Mode",
  69. "内容を正確に認識し、完全な情報を保持": "Accurately recognizes content and retains full information",
  70. "画像/表を認識": "Recognizes images/tables",
  71. "レイアウト情報を保持": "Retains layout information",
  72. "図文混合コンテンツ": "Mixed image and text content",
  73. "API費用が必要": "API cost required",
  74. "処理時間が長い": "Long processing time",
  75. // PDFPreview.tsx
  76. "ズームレベルの状態を追加": "Add zoom level state",
  77. "現在のレンダリングタスクを保存": "Save current rendering task",
  78. "ダウンロード用にpdfUrlを設定": "Set pdfUrl for download",
  79. "PDFデータを取得してblob URLを作成": "Fetch PDF data and create blob URL",
  80. "PDF文書の読み込みとレンダリングを開始": "Start fetching and rendering PDF document",
  81. "ページ切り替えまたはズームレベル変更時に再レンダリング": "Re-render on page change or zoom level change",
  82. "ステータスがpendingの場合、変換を能動的にトリガー": "Actively trigger conversion if status is pending",
  83. "PDF URLにアクセスして変換をトリガー": "Access PDF URL to trigger conversion",
  84. "進行中のレンダリングタスクが存在する場合、キャンセルする": "Cancel rendering task if one is in progress",
  85. "ページめくり後のスクロール位置調整": "Adjust scroll position after page turn",
  86. "pdfUrlが既にある場合、直接ダウンロード": "Directly download if pdfUrl already exists",
  87. "pdfUrlがない場合、直接取得してダウンロードを試みる": "Try fetching and downloading if pdfUrl does not exist",
  88. "pdfUrlがない場合、直接取得して開くことを試みる": "Try fetching and opening if pdfUrl does not exist",
  89. "状態をリセットして再読み込みをトリガー": "Reset state and trigger reload",
  90. "連続ページめくりを防止": "Prevent rapid page turning",
  91. "下にスクロールして次のページへ": "Scroll down for next page",
  92. "上にスクロールして前のページへ": "Scroll up for previous page",
  93. "头部": "Header",
  94. "内容区域": "Content Area",
  95. "エラーを無視し、デフォルト状態を使用": "Ignore error and use default state",
  96. // PDFSelectionTool.tsx
  97. "オプションのズームレベルパラメータ": "Optional zoom level parameter",
  98. "デフォルトのズームレベルは1.0": "Default zoom level is 1.0",
  99. "コンテナに対する実際の座標を使用": "Use actual coordinates relative to container",
  100. // SettingsModal.tsx
  101. "モデル一覧を再取得するためにページをリロード": "Reload page to fetch model list again",
  102. "言語セクション": "Language section",
  103. "中文": "Chinese",
  104. "日本語": "Japanese",
  105. "サイドバー": "Sidebar",
  106. "コンテンツエリア": "Content Area",
  107. // Toast.tsx
  108. "等待动画完成": "Wait for animation to complete",
  109. // ChatView.tsx
  110. "历史记录按钮": "History button",
  111. "新建对话按钮": "New chat button",
  112. "知识库增强功能模态框": "Knowledge base enhancement features modal",
  113. // SettingsView.tsx
  114. "ユーザー一覧の取得(ユーザータブがアクティブな場合)": "Fetch user list (if users tab is active)",
  115. "一般タブのハンドラー": "General tab handlers",
  116. "ユーザータブのハンドラー": "Users tab handlers",
  117. "ユーザーリストを再取得": "Re-fetch user list",
  118. "モデルタブのハンドラー": "Models tab handlers",
  119. "レンダリング関数": "Rendering functions",
  120. "パスワード変更セクション": "Change password section",
  121. "语言设置セクション": "Language settings section",
  122. // ToastContext.tsx
  123. "相同消息去重:如果已存在相同的消息(类型和内容相同),则先移除旧的": "Deduplicate identical messages: discard old one if current type and content are the same",
  124. // apiClient.ts
  125. "新しい API 呼び出し方法、{ data, status } を返す": "New API call method, returns { data, status }",
  126. // chatService.ts
  127. "追加: 選択された LLM ID": "Added: Selected LLM ID",
  128. "追加: 選択されたグループ": "Added: Selected groups",
  129. "追加: 選択されたファイル": "Added: Selected files",
  130. "追加: 会話履歴 ID": "Added: Conversation history ID",
  131. "追加: Rerank を有効にする": "Added: Enable Rerank",
  132. "追加: Rerank モデル ID": "Added: Rerank model ID",
  133. "追加: temperature パラメータ": "Added: temperature parameter",
  134. "追加: maxTokens パラメータ": "Added: maxTokens parameter",
  135. "追加: topK パラメータ": "Added: topK parameter",
  136. "追加: similarityThreshold パラメータ": "Added: similarityThreshold parameter",
  137. "追加: rerankSimilarityThreshold パラメータ": "Added: rerankSimilarityThreshold parameter",
  138. "追加: enableQueryExpansion": "Added: enableQueryExpansion",
  139. "追加: enableHyDE": "Added: enableHyDE",
  140. "追加": "Added",
  141. "グループフィルタパラメータを渡す": "Pass group filter parameters",
  142. "ファイルフィルタパラメータを渡す": "Pass file filter parameters",
  143. "履歴 ID を渡す": "Pass history ID",
  144. "temperature パラメータを渡す": "Pass temperature parameter",
  145. "maxTokens パラメータを渡す": "Pass maxTokens parameter",
  146. "topK パラメータを渡す": "Pass topK parameter",
  147. "similarityThreshold パラメータを渡す": "Pass similarityThreshold parameter",
  148. "rerankSimilarityThreshold パラメータを渡す": "Pass rerankSimilarityThreshold parameter",
  149. "enableQueryExpansion を渡す": "Pass enableQueryExpansion",
  150. "enableHyDE を渡す": "Pass enableHyDE",
  151. "リクエストに失敗しました": "Request failed",
  152. "サーバーエラー": "Server error",
  153. "レスポンスストリームを読み取れません": "Cannot read response stream",
  154. "ネットワークエラー": "Network error",
  155. // chunkConfigService.ts
  156. "チャンク設定サービス - チャンク設定の制限の取得と検証に使用": "Chunk configuration service - Used to fetch and validate chunk configuration limits",
  157. "最大チャンクサイズ": "Max chunk size",
  158. "最大重複サイズ": "Max overlap size",
  159. "最小重複サイズ": "Min overlap size",
  160. "デフォルトチャンクサイズ": "Default chunk size",
  161. "デフォルト重複サイズ": "Default overlap size",
  162. "モデル情報": "Model info",
  163. "モデル名": "Model name",
  164. "モデル入力制限": "Model input limit",
  165. "モデルバッチ制限": "Model batch limit",
  166. "期待されるベクトル次元数": "Expected vector dimensions",
  167. "チャンク設定の制限を取得": "Fetch chunk configuration limits",
  168. "埋め込みモデルID": "Embedding model ID",
  169. "認証トークン": "Auth token",
  170. "設定制限情報": "Configuration limit info",
  171. "チャンク設定が有効かどうかを検証": "Validate if chunk configuration is valid",
  172. "チャンクサイズ": "Chunk size",
  173. "重複サイズ": "Overlap size",
  174. "設定制限": "Config limits",
  175. "検証結果とエラー情報": "Validation results and error info",
  176. "チャンクサイズの検証": "Validate chunk size",
  177. "が上限": " exceeds limit ",
  178. "を超えています": "",
  179. "が最小値": " is below minimum ",
  180. "未満です": "",
  181. "重複サイズの検証": "Validate overlap size",
  182. "がチャンクサイズの50%": " exceeds 50% of chunk size ",
  183. "表示用に制限情報をフォーマット": "Format limit info for display",
  184. "モデル:": "Model:",
  185. "チャンク上限:": "Max Chunk:",
  186. "重複上限:": "Max Overlap:",
  187. "バッチ制限:": "Batch Limit:",
  188. "ベクトル次元:": "Vector Dimensions:",
  189. // geminiService.ts
  190. "请始终使用中文回答。": "Please always answer in English.",
  191. "常に日本語で答えてください。": "Please always answer in English.",
  192. "RAG検索(知識ベースファイルがある場合)": "RAG search (when knowledge base files exist)",
  193. "検索ステータスがリセットされていることを確認": "Ensure search status is reset",
  194. "APIキーはオプションです - ローカルモデルを許可します": "API key is optional - allow local models",
  195. "より詳細なエラー情報を提供": "Provide more detailed error information",
  196. "ネットワーク接続に失敗しました。サーバーの状態を確認してください": "Network connection failed. Please check server status",
  197. // knowledgeGroupService.ts
  198. "すべてのグループを取得": "Fetch all groups",
  199. "グループを作成": "Create group",
  200. "グループを更新": "Update group",
  201. "グループを削除": "Delete group",
  202. "グループ内のファイルを取得": "Fetch files in group",
  203. "ファイルをグループに追加": "Add file to group",
  204. "グループからファイルを削除": "Remove file from group",
  205. // noteService.ts
  206. "すべてのノートを取得(オプションでグループによるフィルタリングが可能)": "Fetch all notes (optional group filtering)",
  207. "ノートを作成": "Create note",
  208. "ノートを更新": "Update note",
  209. "ノートを削除": "Delete note",
  210. "ノートを知識ベースにインデックス(ベクトル化)": "Index note to knowledge base (vectorize)",
  211. // ocrService.ts
  212. "OCR サービス - 画像テキスト認識関連の処理を担当": "OCR Service - Handles image text recognition",
  213. "画像内のテキストを認識": "Recognize text in image",
  214. // pdfPreviewService.ts
  215. "PDFプレビューサービス - PDFファイルのプレビュー状態と変換処理の管理を担当": "PDF Preview Service - Manages PDF preview state and conversion processing",
  216. "PDFファイルがプレビュー可能か(画像に変換済みか)を確認": "Check if PDF file is previewable (converted to image)",
  217. "ファイル情報またはPDF URL": "File info or PDF URL",
  218. "認証状態用のトークン": "Auth token",
  219. "変換状態": "Conversion state",
  220. "存在しない場合はPDFの画像変換をトリガー": "Trigger PDF image conversion if not exists",
  221. "この時点で変換ジョブがキューに追加されたとみなす": "At this point, assume conversion job has been queued",
  222. // ragService.ts
  223. "RAG(Retrieval-Augmented Generation)サービス": "RAG (Retrieval-Augmented Generation) Service",
  224. "ベクトル検索、ハイブリッド検索、再ランキング機能を提供": "Provides vector search, hybrid search, and reranking functionalities",
  225. "チャンクテキスト": "Chunk text",
  226. "スコア(類似度)": "Score (similarity)",
  227. "ソースファイルのID": "Source file ID",
  228. "ソースファイルの元の名前": "Original source file name",
  229. "チャンクのインデックス": "Chunk index",
  230. "チャンクのメタデータ": "Chunk metadata",
  231. "検索結果": "Search results",
  232. "元のユーザーの質問": "Original user question",
  233. "拡張されたクエリ(クエリ拡張が有効な場合)": "Expanded queries (if query expansion is enabled)",
  234. "ベクトル検索を実行": "Execute vector search",
  235. "質問テキスト": "Question text",
  236. "使用する埋め込みモデルのID": "Embedding model ID to use",
  237. "オプションのフィルタ(グループ等)": "Optional filters (groups, etc)",
  238. "再ランキングモデルを実行": "Execute reranking model",
  239. "検索パラメーター": "Search parameters",
  240. // searchHistoryService.ts
  241. "検索とチャットの履歴を管理するサービス": "Service for managing search and chat history",
  242. "最新の履歴から順に取得": "Fetch history in descending order",
  243. "ページ番号": "Page number",
  244. "1ページあたりの件数": "Items per page",
  245. "指定したIDの履歴詳細(メッセージを含む)を取得": "Fetch history details (including messages) for specific ID",
  246. "新しい履歴エントリを作成": "Create new history entry",
  247. "最初のメッセージから生成されたタイトル": "Title generated from first message",
  248. "指定した履歴を削除": "Delete specified history",
  249. "既存の履歴を更新(タイトル等)": "Update existing history (title, etc)",
  250. "更新するデータ": "Data to update",
  251. // uploadService.ts
  252. "チャンク設定付きでファイルをアップロード": "Upload file with chunk configuration",
  253. "アップロードするファイル": "File to upload",
  254. "テキストコンテンツを直接アップロードして処理": "Directly upload and process text content",
  255. "テキストコンテンツ": "Text content",
  256. "アップロード用のタイトル/ファイル名": "Title/filename for upload",
  257. "チャンク設定": "Chunk configuration",
  258. "ファイルモードの推奨を取得": "Get recommended file mode",
  259. // Other Server files
  260. "コストを重視したVision Pipelineを使用して画像をテキストに変換": "Convert image to text using cost-aware Vision Pipeline",
  261. // translation_map.json
  262. " `💰 推定コスト: $${estimatedCost.toFixed(2)}, 推定時間: ${duration.toFixed(1)}s`\n )": " `💰 Estimated cost: $${estimatedCost.toFixed(2)}, Estimated time: ${duration.toFixed(1)}s`\n )",
  263. " this.logger.log(`💰 推定コスト: $${estimatedCost.toFixed(2)}, 推定時間: ${duration.toFixed(1)}s`);": " this.logger.log(`💰 Estimated cost: $${estimatedCost.toFixed(2)}, Estimated time: ${duration.toFixed(1)}s`);",
  264. "チャンクサイズ ${chunkSize} が上限 ${limits.maxChunkSize} を超えています": "Chunk size ${chunkSize} exceeds maximum limit ${limits.maxChunkSize}",
  265. "チャンクサイズ ${chunkSize} が最小値 50 未満です": "Chunk size ${chunkSize} is below minimum 50",
  266. "重複サイズ ${chunkOverlap} が上限 ${limits.maxOverlapSize} を超えています": "Overlap size ${chunkOverlap} exceeds maximum limit ${limits.maxOverlapSize}",
  267. "重複サイズ ${chunkOverlap} がチャンクサイズの50% (${maxOverlapByRatio}) を超えています": "Overlap size ${chunkOverlap} exceeds 50% of chunk size (${maxOverlapByRatio})"
  268. };
  269. function walkSync(currentDirPath, callback) {
  270. fs.readdirSync(currentDirPath).forEach((name) => {
  271. const filePath = path.join(currentDirPath, name);
  272. const stat = fs.statSync(filePath);
  273. if (stat.isFile()) {
  274. callback(filePath);
  275. } else if (stat.isDirectory() && !excludeDirs.includes(name)) {
  276. walkSync(filePath, callback);
  277. }
  278. });
  279. }
  280. let modifiedCount = 0;
  281. directories.forEach(d => {
  282. walkSync(d, (filePath) => {
  283. if (extensions.some(ext => filePath.endsWith(ext))) {
  284. try {
  285. let content = fs.readFileSync(filePath, 'utf-8');
  286. let originalContent = content;
  287. for (const [key, value] of Object.entries(translations)) {
  288. content = content.split(key).join(value);
  289. }
  290. if (content !== originalContent) {
  291. fs.writeFileSync(filePath, content, 'utf-8');
  292. console.log(`Updated: ${filePath}`);
  293. modifiedCount++;
  294. }
  295. } catch (e) {
  296. console.error(`Error reading ${filePath}: `, e);
  297. }
  298. }
  299. });
  300. });
  301. console.log(`Updated ${modifiedCount} files`);