dsh-cait 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/README.ja.md +53 -13
- package/README.md +58 -16
- package/README.zh-CN.md +53 -15
- package/client/components.js +32 -1
- package/client/locales.js +27 -6
- package/client/rpc.js +1 -1
- package/client.js +60 -8
- package/lib/docx.js +12 -9
- package/lib/epub.js +355 -0
- package/lib/formats.js +88 -33
- package/lib/html.js +271 -0
- package/lib/import-export.js +136 -91
- package/lib/persistence.js +20 -0
- package/lib/preprocess.js +65 -0
- package/lib/store-utils.js +6 -3
- package/lib/store.js +12 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,48 @@ All notable changes to CAIT are documented here. The project follows
|
|
|
4
4
|
[Semantic Versioning](https://semver.org/) and the format is based on
|
|
5
5
|
[Keep a Changelog](https://keepachangelog.com/).
|
|
6
6
|
|
|
7
|
+
## [1.0.5] - 2026-11-06
|
|
8
|
+
|
|
9
|
+
EPUB support, an import preprocessing stage, and format hardening.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- EPUB 3 import and export. Import walks the OPF spine, turns XHTML text blocks
|
|
14
|
+
into segments, and keeps inline tags as placeholder tokens; export patches the
|
|
15
|
+
translations back into the retained source package, preserving chapters,
|
|
16
|
+
styles, images, and navigation. Documents created from plain text export as a
|
|
17
|
+
fresh EPUB 3 package. DRM, fixed-layout, and scripted EPUBs are out of scope.
|
|
18
|
+
- Import preprocessing: whitespace normalization, invisible/control character
|
|
19
|
+
stripping, and blank-line collapsing before segmentation. Each step has a
|
|
20
|
+
settings toggle, applies to file imports and `createDocument`, and is stored
|
|
21
|
+
with the other settings.
|
|
22
|
+
- A shared HTML/XHTML run scanner (`lib/html.js`) used by both HTML and EPUB, so
|
|
23
|
+
headings and inline markup survive import and are patched back on export.
|
|
24
|
+
- CSV delimiter detection (comma, semicolon, tab, pipe) and richer RTF escapes
|
|
25
|
+
(`\cell`, `\row`, `\page`, `\sect`, symbol characters).
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- PDF import is explicitly out of scope. All three READMEs explain why PDF is a
|
|
30
|
+
poor fit for AI-assisted translation and recommend converting it with pandoc,
|
|
31
|
+
Acrobat, or LibreOffice first.
|
|
32
|
+
- The supported-formats table, project layout, roadmap, and “Known limits”
|
|
33
|
+
sections now describe EPUB, preprocessing, and the PDF policy.
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- Settings persistence now stores `uiLang` and the preprocessing flags instead of
|
|
38
|
+
falling back to defaults on reload.
|
|
39
|
+
- The EPUB `mimetype` entry is written uncompressed, as the OCF specification
|
|
40
|
+
requires, and every other entry stays deflated.
|
|
41
|
+
- HTML import no longer flattens headings and inline markup into blank-line
|
|
42
|
+
paragraphs.
|
|
43
|
+
|
|
44
|
+
### Development
|
|
45
|
+
|
|
46
|
+
- New `_dev/test-epub.mjs` and `_dev/test-preprocess.mjs` suites; the full suite
|
|
47
|
+
count is 15.
|
|
48
|
+
|
|
7
49
|
## [1.0.4] - 2026-11-05
|
|
8
50
|
|
|
9
51
|
Provenance publishing.
|
|
@@ -365,3 +407,4 @@ directory (`$DSH_HOME/cait`), and API route (`/cait/api`) keep the CAIT name.
|
|
|
365
407
|
| 2026-11-04 | First-tier exchange formats: CSV mapping, SRT, WebVTT, PO, XLIFF 1.2, metadata persistence, timeline fixes. |
|
|
366
408
|
| 2026-11-04 | Second-tier formats: HTML, JSON, XLSX, PPTX, RTF; binary upload/export; source-preserving PPTX. |
|
|
367
409
|
| 2026-11-04 | Responsive UI density 1×–1.8×; button contrast fix; v1.0.0 release. |
|
|
410
|
+
| 2026-11-06 | EPUB 3 import/export with source-package patching, shared HTML/XHTML scanner, import preprocessing stage, CSV/RTF hardening, PDF out of scope; v1.0.5 release. |
|
package/README.ja.md
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<p align="center">
|
|
18
18
|
<a href="https://www.npmjs.com/package/dsh-cait"><img alt="npm バージョン" src="https://img.shields.io/npm/v/dsh-cait.svg" /></a>
|
|
19
19
|
<img alt="DSH 0.2.x" src="https://img.shields.io/badge/DSH-0.2.x-4d6bfe.svg" />
|
|
20
|
-
<img alt="テスト
|
|
20
|
+
<img alt="テスト 15 スイート" src="https://img.shields.io/badge/tests-15%20suites-brightgreen.svg" />
|
|
21
21
|
<img alt="API キー不要" src="https://img.shields.io/badge/API%20key-not%20required-6b7280.svg" />
|
|
22
22
|
</p>
|
|
23
23
|
|
|
@@ -37,7 +37,7 @@ CAIT は DSH Web UI と DSH デスクトップに CAT ワークベンチを追
|
|
|
37
37
|
| **説明できる翻訳メモリ** | 複数の TM ライブラリ、マウント済みライブラリのみの検索、完全一致 / ほぼ完全一致 / 高・中・低ファジーの段階、確定時の自動書き戻し。 |
|
|
38
38
|
| **用語を意識した編集** | 複数の用語集、ソース言語による絞り込み、インライン強調、用語のクリック挿入、用語ごとの大文字小文字の区別。 |
|
|
39
39
|
| **文書ワークフロー** | タブ、閉じる / 開き直し、最近の文書の整理、同一内容の再インポート再利用、文書ごとの進捗。 |
|
|
40
|
-
| **実用的な形式対応** | TXT、Markdown、DOCX、TMX、CSV、SRT/VTT、PO、XLIFF 1.2/2.0/SDLXLIFF、HTML、JSON、XLSX、PPTX、RTF。 |
|
|
40
|
+
| **実用的な形式対応** | TXT、Markdown、DOCX、EPUB、TMX、CSV、SRT/VTT、PO、XLIFF 1.2/2.0/SDLXLIFF、HTML、JSON、XLSX、PPTX、RTF。 |
|
|
41
41
|
| **エージェント対応** | 7 つのツールが開いている文書とストアを共有するので、エージェントと並行して翻訳できます。 |
|
|
42
42
|
|
|
43
43
|
## クイックスタート
|
|
@@ -100,6 +100,17 @@ Host のリビジョンをポーリングするため、エージェントによ
|
|
|
100
100
|
1×–1.8× で適用します。1600×900 のパネルは約 1.32×、2560×1440 は 1.8×。
|
|
101
101
|
高さの低いウィンドウでは縮小せず 1× のままです。
|
|
102
102
|
|
|
103
|
+
### 前処理
|
|
104
|
+
|
|
105
|
+
インポートした原文は、分割の前に前処理ステージを通ります:
|
|
106
|
+
|
|
107
|
+
- 連続する空白とタブを畳み、行頭のインデントを除き、連続する空行をまとめます。
|
|
108
|
+
- ゼロ幅文字と余分な制御文字を除去します。
|
|
109
|
+
- プレースホルダートークン(`{1}`、`{2}`…)、句読点、大文字小文字、段落順は
|
|
110
|
+
変更しません。XLIFF/HTML/EPUB のインラインマークアップはそのまま往復できます。
|
|
111
|
+
- 3 つの手順は **設定 → 前処理** で個別に切り替えられ、他の設定と一緒に保存されます。
|
|
112
|
+
新しいインポートと `createDocument` 呼び出しに適用され、既存の文書は書き換えません。
|
|
113
|
+
|
|
103
114
|
### MT 支援
|
|
104
115
|
|
|
105
116
|
CAIT はエンドポイントもキーも持ちません。セレクタは DSH から組み立てます:
|
|
@@ -120,15 +131,16 @@ CAIT はエンドポイントもキーも持ちません。セレクタは DSH
|
|
|
120
131
|
| 形式 | インポート | エクスポート | 備考 |
|
|
121
132
|
| --- | :---: | :---: | --- |
|
|
122
133
|
| TXT / Markdown | ✅ | ✅ | 段落と文のセグメンテーション |
|
|
123
|
-
| CSV | ✅ | ✅ |
|
|
134
|
+
| CSV | ✅ | ✅ | カンマ、セミコロン、タブ、パイプの区切りを自動判定。ヘッダー名または 1 始まりの番号でソース / ターゲット列を指定可能。既存の対訳エクスポートにも対応 |
|
|
124
135
|
| DOCX | ✅ | ✅ | 本文段落。表ブロックはインポート対象外。エクスポートは元のパッケージにパッチを当て、スタイル、番号付け、画像、ヘッダー、表、レイアウトを保つ |
|
|
136
|
+
| EPUB | ✅ | ✅ | EPUB 3 の spine 順に XHTML テキストブロックを読み、インライン要素をトークンとして保持し、保持したソースパッケージに書き戻す。DRM、固定レイアウト、スクリプト化された EPUB は非対応 |
|
|
125
137
|
| TMX 1.4 | ✅ | ✅ | 一般的な `<tu>/<tuv>/<seg>` サブセット。インライン要素は警告付きで平坦化 |
|
|
126
138
|
| SRT / WebVTT | ✅ | ✅ | 1 キュー = 1 セグメント。タイミング / 設定 / 識別子を保持し、セマンティックタグも維持。不正な範囲は拒否 |
|
|
127
139
|
| PO | ✅ | ✅ | コンテキスト、複数形、翻訳者コメント、廃止された `#~` エントリ |
|
|
128
140
|
| XLIFF 1.2 | ✅ | ✅ | インラインタグは `{n}` トークンになり、欠落していると確定できない |
|
|
129
141
|
| XLIFF 2.0 | ✅ | ✅ | `<unit><segment><source>/<target>` の基本サブセット |
|
|
130
142
|
| SDLXLIFF | ✅ | ✅ | XLIFF 1.2 の基本パス。SDL 固有の拡張はラウンドトリップしない |
|
|
131
|
-
| HTML | ✅ | ✅ |
|
|
143
|
+
| HTML | ✅ | ✅ | テキストブロックとインラインタグを保持。文書全体の CSS / レイアウトは再構築しない |
|
|
132
144
|
| JSON | ✅ | ✅ | 文字列パスのサブセット。オブジェクト / 配列構造はテンプレートで保持。キーと数値は翻訳しない |
|
|
133
145
|
| XLSX | ✅ | ✅ | 最初のワークシート。`Source`/`Target` ヘッダーまたは A/B 列。エクスポートは 2 列の新しいワークブック |
|
|
134
146
|
| PPTX | ✅ | ✅* | ソース保持エクスポート。インポートした `.pptx` パッケージが必要。本文テキストのみで、ノート / グラフ / SmartArt はインポートしない |
|
|
@@ -139,7 +151,26 @@ CAIT はエンドポイントもキーも持ちません。セレクタは DSH
|
|
|
139
151
|
|
|
140
152
|
交換メタデータ(字幕のタイミング、PO のコンテキスト / 複数形 / コメント、XLIFF の id と
|
|
141
153
|
インライントークンマップ、JSON のパス / テンプレート、XLSX の行、PPTX のスライド /
|
|
142
|
-
|
|
154
|
+
段落位置、EPUB の spine href とブロック番号)は文書とセグメントに保持され、
|
|
155
|
+
スナップショットに永続化されます。
|
|
156
|
+
|
|
157
|
+
### PDF はサポートされません
|
|
158
|
+
|
|
159
|
+
CAIT は PDF をインポートせず、今後のリリースでも PDF 対応を追加しません。PDF は
|
|
160
|
+
固定レイアウトの印刷形式で、論理的な段落、読み順、インラインマークアップを持ちません。
|
|
161
|
+
抽出したテキストは描画命令の間に断片化し、見出し、表、インライン強調が失われるため、
|
|
162
|
+
翻訳メモリや MT にとって質の低い入力になります。つまり PDF は AI 関連の作業に
|
|
163
|
+
極めて不向きです。
|
|
164
|
+
|
|
165
|
+
PDF の内容を翻訳する場合は、先にサポート形式へ変換してください。例えば:
|
|
166
|
+
|
|
167
|
+
```sh
|
|
168
|
+
pandoc input.pdf -t docx -o output.docx # または -t html、-t markdown
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Adobe Acrobat の **Word/HTML へエクスポート**、LibreOffice、その他 DOCX、HTML、
|
|
172
|
+
EPUB、プレーンテキストを生成できるツールでも構いません。スキャン PDF は変換前に
|
|
173
|
+
OCR が必要です。CAIT に画像 OCR ステージはありません。
|
|
143
174
|
|
|
144
175
|
## インストール
|
|
145
176
|
|
|
@@ -156,7 +187,7 @@ DSH デスクトップ(または `plugin_manager` ツールがある任意の
|
|
|
156
187
|
plugin_manager install_bundle target: dsh-cait
|
|
157
188
|
```
|
|
158
189
|
|
|
159
|
-
バージョンを固定するときは `dsh-cait@1.0.
|
|
190
|
+
バージョンを固定するときは `dsh-cait@1.0.5`、最新版は `dsh-cait@latest` を指定します。
|
|
160
191
|
マネージャが registry のパッケージを解決し、bundle patch を適用してプラグインを有効化します。
|
|
161
192
|
|
|
162
193
|
CLI 管理のプロファイル:
|
|
@@ -222,7 +253,7 @@ dsh web --patch C:\absolute\path\to\dsh-CAIT\_dev\cait.patch.yml
|
|
|
222
253
|
```
|
|
223
254
|
|
|
224
255
|
スナップショットには文書、開いているタブ、TM、用語集、ライブラリ、マウント、そして
|
|
225
|
-
秘密でない設定が保存されます。インポートした DOCX/PPTX のソースパッケージは `sources/`
|
|
256
|
+
秘密でない設定が保存されます。インポートした DOCX/PPTX/EPUB のソースパッケージは `sources/`
|
|
226
257
|
に置かれます。
|
|
227
258
|
|
|
228
259
|
アプリ内設定(**設定**)は上記の YAML ではなくスナップショットに保存されます: ソース /
|
|
@@ -300,6 +331,9 @@ cait/
|
|
|
300
331
|
│ ├─ persistence.js
|
|
301
332
|
│ ├─ import-export.js
|
|
302
333
|
│ ├─ formats.js # CSV/SRT/VTT/PO/XLIFF/HTML/JSON/RTF
|
|
334
|
+
│ ├─ html.js # HTML/XHTML テキストラン走査と書き戻し
|
|
335
|
+
│ ├─ epub.js # EPUB パッケージ読み込み / spine インポート / パッチ書き出し
|
|
336
|
+
│ ├─ preprocess.js # インポート時の原文前処理ステージ
|
|
303
337
|
│ ├─ xlsx.js
|
|
304
338
|
│ ├─ pptx.js
|
|
305
339
|
│ ├─ segmenter.js
|
|
@@ -327,6 +361,8 @@ node --check client.js
|
|
|
327
361
|
node _dev/test-core.mjs
|
|
328
362
|
node _dev/test-imports.mjs
|
|
329
363
|
node _dev/test-formats.mjs
|
|
364
|
+
node _dev/test-epub.mjs
|
|
365
|
+
node _dev/test-preprocess.mjs
|
|
330
366
|
node _dev/test-second-tier.mjs
|
|
331
367
|
node _dev/test-docx-export.mjs
|
|
332
368
|
node _dev/test-api.mjs
|
|
@@ -341,7 +377,7 @@ node _dev/test-mt.mjs
|
|
|
341
377
|
|
|
342
378
|
インポート / エクスポートのフィクスチャは `_dev/sample.docx`、`_dev/sample-table.docx`、
|
|
343
379
|
`_dev/sample-format.docx` です。対応する `python _dev/make-*.py` スクリプトで再生成
|
|
344
|
-
できます。
|
|
380
|
+
できます。15 スイートすべてが通るはずです。
|
|
345
381
|
|
|
346
382
|
### リリース
|
|
347
383
|
|
|
@@ -383,7 +419,10 @@ npm publish
|
|
|
383
419
|
|
|
384
420
|
## 既知の制限とロードマップ
|
|
385
421
|
|
|
386
|
-
- PDF
|
|
422
|
+
- PDF のインポートは非対応で、今後も対象外です([PDF はサポートされません](#pdf-はサポートされません))。
|
|
423
|
+
画像 OCR も未対応です。
|
|
424
|
+
- EPUB インポートは spine 内の本文 XHTML テキストブロックのみを対象とします。
|
|
425
|
+
DRM、固定レイアウト、スクリプト化、MathML を多用する書籍は非対応です。
|
|
387
426
|
- DOCX インポートは表、ヘッダー、脚注、フィールド、代替テキスト、変更履歴の削除を
|
|
388
427
|
スキップします。DOCX エクスポートではそれらの領域はソース言語のまま残ります。
|
|
389
428
|
- 複数の run が混在する DOCX/PPTX の段落は、先頭 run の書式を継承します。
|
|
@@ -393,12 +432,12 @@ npm publish
|
|
|
393
432
|
- HTML/RTF のエクスポートは元のスタイルをラウンドトリップしません。JSON は文字列値だけを
|
|
394
433
|
翻訳します。
|
|
395
434
|
- TM のマッチングは意味ではなく字句に基づきます。ステミング、同義語、埋め込みはありません。
|
|
396
|
-
- ライブラリの名前変更 /
|
|
435
|
+
- ライブラリの名前変更 / 削除と、タブごとのマウント状態は未実装です。
|
|
397
436
|
- ワークベンチ UI は中国語・英語・日本語の 3 言語で、設定から切り替えられます。
|
|
398
437
|
README も英語・簡体字中国語・日本語の 3 版があり、英語版が正本です。
|
|
399
438
|
|
|
400
|
-
|
|
401
|
-
|
|
439
|
+
次に予定しているのは、マルチモーダルな DSH ルート経由の画像 / ビジョン入力、
|
|
440
|
+
より充実したライブラリ管理、スタイルを保つ XLSX 出力、XLIFF の
|
|
402
441
|
`<alt-trans>` / ノート対応です。
|
|
403
442
|
|
|
404
443
|
## 変更履歴とバージョン
|
|
@@ -406,7 +445,8 @@ npm publish
|
|
|
406
445
|
[CHANGELOG.md](CHANGELOG.md) を参照してください。`v1.0.0` が最初の公開リリースで、
|
|
407
446
|
`v1.0.1` が日本語 UI とアプリ内の UI 言語切り替えを追加し、`v1.0.2` で
|
|
408
447
|
*DSH の言語に従う* が DSH のロケールに従うようになり、`v1.0.3` で npm に公開、
|
|
409
|
-
`v1.0.4` から以降のリリースは provenance
|
|
448
|
+
`v1.0.4` から以降のリリースは provenance 付きの公開ワークフローで行われ、
|
|
449
|
+
`v1.0.5` で EPUB、インポート前処理、PDF ポリシーを追加しました。
|
|
410
450
|
プロジェクトは `0.1.0` として開発され、GitHub リリースに向けて採番し直されました。
|
|
411
451
|
|
|
412
452
|
> **ライセンス:** Apache License 2.0 — [LICENSE](LICENSE) を参照してください。
|
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<p align="center">
|
|
17
17
|
<a href="https://www.npmjs.com/package/dsh-cait"><img alt="npm version" src="https://img.shields.io/npm/v/dsh-cait.svg" /></a>
|
|
18
18
|
<img alt="DSH 0.2.x" src="https://img.shields.io/badge/DSH-0.2.x-4d6bfe.svg" />
|
|
19
|
-
<img alt="Tests:
|
|
19
|
+
<img alt="Tests: 15 suites" src="https://img.shields.io/badge/tests-15%20suites-brightgreen.svg" />
|
|
20
20
|
<img alt="No API key required" src="https://img.shields.io/badge/API%20key-not%20required-6b7280.svg" />
|
|
21
21
|
</p>
|
|
22
22
|
|
|
@@ -37,7 +37,7 @@ translated document.
|
|
|
37
37
|
| **TM that explains itself** | Multiple TM libraries, mounted-only lookup, exact / near-exact / high / medium / low fuzzy grades, and automatic write-back on confirm. |
|
|
38
38
|
| **Glossary-aware editing** | Multiple term bases, source-language filtering, inline highlighting, click-to-insert terms, and per-term case sensitivity. |
|
|
39
39
|
| **A document workflow** | Tabs, close/reopen, recent-document cleanup, duplicate-import reuse, and progress per document. |
|
|
40
|
-
| **Real format coverage** | TXT, Markdown, DOCX, TMX, CSV, SRT/VTT, PO, XLIFF 1.2/2.0/SDLXLIFF, HTML, JSON, XLSX, PPTX, and RTF. |
|
|
40
|
+
| **Real format coverage** | TXT, Markdown, DOCX, EPUB, TMX, CSV, SRT/VTT, PO, XLIFF 1.2/2.0/SDLXLIFF, HTML, JSON, XLSX, PPTX, and RTF. |
|
|
41
41
|
| **Agent-ready** | Seven tools share the open document and store, so an agent can translate alongside you. |
|
|
42
42
|
|
|
43
43
|
## Quick start
|
|
@@ -104,6 +104,19 @@ manual reload.
|
|
|
104
104
|
`--cait-u` multiplier of 1×–1.8×. A 1600×900 panel renders at ~1.32× and a
|
|
105
105
|
2560×1440 panel at 1.8×; short windows stay at 1× rather than shrinking.
|
|
106
106
|
|
|
107
|
+
### Preprocessing
|
|
108
|
+
|
|
109
|
+
Imported source text passes through a preprocessing stage before segmentation:
|
|
110
|
+
|
|
111
|
+
- Collapse repeated spaces and tabs, trim indentation, and merge consecutive
|
|
112
|
+
blank lines.
|
|
113
|
+
- Remove zero-width characters and stray control characters.
|
|
114
|
+
- Placeholder tokens (`{1}`, `{2}`, …), punctuation, casing, and paragraph order
|
|
115
|
+
are left untouched, so XLIFF/HTML/EPUB inline markup still round-trips.
|
|
116
|
+
- The three steps are independently switchable in **Settings → Preprocessing** and
|
|
117
|
+
are persisted with the other settings. They apply to new imports and
|
|
118
|
+
`createDocument` calls; existing documents are not rewritten.
|
|
119
|
+
|
|
107
120
|
### MT assistance
|
|
108
121
|
|
|
109
122
|
CAIT does not own an endpoint or key. The selector is built from DSH:
|
|
@@ -125,15 +138,16 @@ provider/model/code/status; the client receives only `MT_PROVIDER_FAILED`.
|
|
|
125
138
|
| Format | Import | Export | Notes |
|
|
126
139
|
| --- | :---: | :---: | --- |
|
|
127
140
|
| TXT / Markdown | ✅ | ✅ | Paragraph and sentence segmentation |
|
|
128
|
-
| CSV | ✅ | ✅ |
|
|
141
|
+
| CSV | ✅ | ✅ | Comma, semicolon, tab, or pipe delimiter auto-detected; source/target column by header name or 1-based number; existing bilingual export |
|
|
129
142
|
| DOCX | ✅ | ✅ | Body paragraphs; table blocks are excluded from import. Export patches the original package, keeping styles, numbering, images, headers, tables, and layout. |
|
|
143
|
+
| EPUB | ✅ | ✅ | EPUB 3 spine order; XHTML text blocks with inline markup kept as tokens and patched back into the retained package. DRM-protected, fixed-layout, and scripted EPUBs are not supported. |
|
|
130
144
|
| TMX 1.4 | ✅ | ✅ | Common `<tu>/<tuv>/<seg>` subset; inline markup flattened with warning |
|
|
131
145
|
| SRT / WebVTT | ✅ | ✅ | One cue per segment, timings/settings/identifier retained; semantic tags kept; invalid ranges rejected |
|
|
132
146
|
| PO | ✅ | ✅ | Contexts, plural forms, translator comments, obsolete `#~` entries |
|
|
133
147
|
| XLIFF 1.2 | ✅ | ✅ | Inline tags become `{n}` tokens; missing tokens block confirmation |
|
|
134
148
|
| XLIFF 2.0 | ✅ | ✅ | Basic `<unit><segment><source>/<target>` subset |
|
|
135
149
|
| SDLXLIFF | ✅ | ✅ | Basic XLIFF 1.2 path; SDL-specific extensions are not round-tripped |
|
|
136
|
-
| HTML | ✅ | ✅ | Text blocks
|
|
150
|
+
| HTML | ✅ | ✅ | Text blocks and inline tags preserved; document CSS/layout is not rebuilt |
|
|
137
151
|
| JSON | ✅ | ✅ | String-path subset; object/array structure preserved via a template; keys and numbers are not translated |
|
|
138
152
|
| XLSX | ✅ | ✅ | First worksheet; `Source`/`Target` headers or columns A/B; export is a new two-column workbook |
|
|
139
153
|
| PPTX | ✅ | ✅* | Source-preserving export; requires the imported `.pptx` package. Body text only; notes/charts/SmartArt not imported. |
|
|
@@ -143,8 +157,28 @@ provider/model/code/status; the client receives only `MT_PROVIDER_FAILED`.
|
|
|
143
157
|
is missing rather than silently producing an unformatted deck.
|
|
144
158
|
|
|
145
159
|
Exchange metadata (subtitle timings, PO contexts/plurals/comments, XLIFF ids and
|
|
146
|
-
inline token maps, JSON paths/templates, XLSX rows, PPTX slide/paragraph positions
|
|
147
|
-
is stored on the document/segments and persists
|
|
160
|
+
inline token maps, JSON paths/templates, XLSX rows, PPTX slide/paragraph positions,
|
|
161
|
+
EPUB spine hrefs and block indexes) is stored on the document/segments and persists
|
|
162
|
+
in the snapshot.
|
|
163
|
+
|
|
164
|
+
### PDF is not supported
|
|
165
|
+
|
|
166
|
+
CAIT does not import PDF, and future releases will not add PDF support. PDF is a
|
|
167
|
+
fixed-layout print format: it has no logical paragraphs, reading order, or inline
|
|
168
|
+
markup. Text extracted from it is fragmented across drawing operations, loses
|
|
169
|
+
headings, tables, and inline emphasis, and produces segments that are poor input
|
|
170
|
+
for translation memory and MT — in other words, PDF is extremely unsuitable for
|
|
171
|
+
AI-related work.
|
|
172
|
+
|
|
173
|
+
To translate PDF content, convert it to a supported format first, for example:
|
|
174
|
+
|
|
175
|
+
```sh
|
|
176
|
+
pandoc input.pdf -t docx -o output.docx # or -t html, -t markdown
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Adobe Acrobat's **Export to Word/HTML**, LibreOffice, or any other converter that
|
|
180
|
+
produces DOCX, HTML, EPUB, or plain text works too. Scanned PDFs need OCR before
|
|
181
|
+
conversion; CAIT has no image OCR stage.
|
|
148
182
|
|
|
149
183
|
## Install
|
|
150
184
|
|
|
@@ -161,7 +195,7 @@ In DSH Desktop (or any profile with the `plugin_manager` tool):
|
|
|
161
195
|
plugin_manager install_bundle target: dsh-cait
|
|
162
196
|
```
|
|
163
197
|
|
|
164
|
-
Pin a release with `dsh-cait@1.0.
|
|
198
|
+
Pin a release with `dsh-cait@1.0.5`, or ask for the newest one with
|
|
165
199
|
`dsh-cait@latest`. The manager resolves the registry package, applies the bundle
|
|
166
200
|
patch, and activates the plugin — no hand-written profile rows.
|
|
167
201
|
|
|
@@ -229,7 +263,7 @@ not both.
|
|
|
229
263
|
```
|
|
230
264
|
|
|
231
265
|
The snapshot stores documents, open tabs, TM, glossary, libraries, mounts, and
|
|
232
|
-
non-secret settings. Imported DOCX/PPTX source packages live in `sources/`.
|
|
266
|
+
non-secret settings. Imported DOCX/PPTX/EPUB source packages live in `sources/`.
|
|
233
267
|
|
|
234
268
|
In-app settings (**Settings**) live in the snapshot rather than in the YAML
|
|
235
269
|
above: source/target language, fuzzy threshold, TM result limit, MT
|
|
@@ -306,6 +340,9 @@ cait/
|
|
|
306
340
|
│ ├─ persistence.js
|
|
307
341
|
│ ├─ import-export.js
|
|
308
342
|
│ ├─ formats.js # CSV/SRT/VTT/PO/XLIFF/HTML/JSON/RTF
|
|
343
|
+
│ ├─ html.js # Shared HTML/XHTML run scanner + patcher
|
|
344
|
+
│ ├─ epub.js # EPUB package read / spine import / patch export
|
|
345
|
+
│ ├─ preprocess.js # Import-time source cleaning stage
|
|
309
346
|
│ ├─ xlsx.js
|
|
310
347
|
│ ├─ pptx.js
|
|
311
348
|
│ ├─ segmenter.js
|
|
@@ -334,6 +371,8 @@ node --check client.js
|
|
|
334
371
|
node _dev/test-core.mjs
|
|
335
372
|
node _dev/test-imports.mjs
|
|
336
373
|
node _dev/test-formats.mjs
|
|
374
|
+
node _dev/test-epub.mjs
|
|
375
|
+
node _dev/test-preprocess.mjs
|
|
337
376
|
node _dev/test-second-tier.mjs
|
|
338
377
|
node _dev/test-docx-export.mjs
|
|
339
378
|
node _dev/test-api.mjs
|
|
@@ -348,7 +387,7 @@ node _dev/test-mt.mjs
|
|
|
348
387
|
|
|
349
388
|
The import/export fixtures are `_dev/sample.docx`, `_dev/sample-table.docx`, and
|
|
350
389
|
`_dev/sample-format.docx`; regenerate them with the matching
|
|
351
|
-
`python _dev/make-*.py` scripts. All
|
|
390
|
+
`python _dev/make-*.py` scripts. All 15 suites should pass.
|
|
352
391
|
|
|
353
392
|
### Releasing
|
|
354
393
|
|
|
@@ -392,7 +431,10 @@ GitHub with a release.
|
|
|
392
431
|
|
|
393
432
|
## Known limits and roadmap
|
|
394
433
|
|
|
395
|
-
- No PDF
|
|
434
|
+
- No PDF import; PDF is intentionally out of scope (see
|
|
435
|
+
[PDF is not supported](#pdf-is-not-supported)). No image OCR yet.
|
|
436
|
+
- EPUB import follows the spine and body XHTML text blocks; DRM-protected,
|
|
437
|
+
fixed-layout, scripted, and MathML-heavy books are not supported.
|
|
396
438
|
- DOCX import skips tables, headers, footnotes, fields, alt text, and tracked
|
|
397
439
|
deletions. DOCX export leaves those regions in the source language.
|
|
398
440
|
- Mixed-run DOCX/PPTX paragraphs inherit the first run's formatting.
|
|
@@ -402,22 +444,22 @@ GitHub with a release.
|
|
|
402
444
|
- HTML/RTF export does not round-trip original styling; JSON translates string
|
|
403
445
|
values only.
|
|
404
446
|
- TM matching is lexical, not semantic; no stemming, synonyms, or embeddings.
|
|
405
|
-
- Library rename/delete and per-tab mount state are not
|
|
447
|
+
- Library rename/delete and per-tab mount state are not implemented yet.
|
|
406
448
|
- The workbench UI ships in Chinese, English, and Japanese, switchable in
|
|
407
449
|
Settings; this README ships in English, Simplified Chinese, and Japanese, and
|
|
408
450
|
the English version is the source of truth.
|
|
409
451
|
|
|
410
|
-
Planned next:
|
|
411
|
-
|
|
412
|
-
`<alt-trans>` / notes support.
|
|
452
|
+
Planned next: image/vision input through a multimodal DSH route, richer library
|
|
453
|
+
management, style-preserving XLSX output, and XLIFF `<alt-trans>` / notes support.
|
|
413
454
|
|
|
414
455
|
## Changelog and versioning
|
|
415
456
|
|
|
416
457
|
See [CHANGELOG.md](CHANGELOG.md). `v1.0.0` was the first public release;
|
|
417
458
|
`v1.0.1` adds the Japanese UI and the in-app interface language switch,
|
|
418
459
|
`v1.0.2` makes *Follow DSH language* honour the DSH locale, `v1.0.3`
|
|
419
|
-
publishes the package to npm,
|
|
420
|
-
provenance-publishing workflow
|
|
460
|
+
publishes the package to npm, `v1.0.4` moves later releases to the
|
|
461
|
+
provenance-publishing workflow, and `v1.0.5` adds EPUB, import preprocessing,
|
|
462
|
+
and the PDF policy. The project was developed as `0.1.0` and
|
|
421
463
|
renumbered for the GitHub release.
|
|
422
464
|
|
|
423
465
|
> **License:** Apache License 2.0 — see [LICENSE](LICENSE). Redistributions must
|
package/README.zh-CN.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<p align="center">
|
|
17
17
|
<a href="https://www.npmjs.com/package/dsh-cait"><img alt="npm 版本" src="https://img.shields.io/npm/v/dsh-cait.svg" /></a>
|
|
18
18
|
<img alt="DSH 0.2.x" src="https://img.shields.io/badge/DSH-0.2.x-4d6bfe.svg" />
|
|
19
|
-
<img alt="
|
|
19
|
+
<img alt="15 套测试" src="https://img.shields.io/badge/tests-15%20suites-brightgreen.svg" />
|
|
20
20
|
<img alt="无需 API Key" src="https://img.shields.io/badge/API%20key-not%20required-6b7280.svg" />
|
|
21
21
|
</p>
|
|
22
22
|
|
|
@@ -35,7 +35,7 @@ CAIT 为 DSH Web UI 和 DSH 桌面端增加一个 CAT 翻译工作台。它从
|
|
|
35
35
|
| **可解释的翻译记忆** | 支持多个 TM 库、仅检索已挂载库、精确/近似精确/高/中/低模糊等级,确认句段时自动写回。 |
|
|
36
36
|
| **术语感知编辑** | 支持多个术语库、按源语言过滤、行内高亮、点击插入术语,以及按术语设置是否区分大小写。 |
|
|
37
37
|
| **完整文档流程** | 文档标签页、关闭/重新打开、最近文档清理、重复导入复用、逐文档进度。 |
|
|
38
|
-
| **真实格式覆盖** | TXT、Markdown、DOCX、TMX、CSV、SRT/VTT、PO、XLIFF 1.2/2.0/SDLXLIFF、HTML、JSON、XLSX、PPTX、RTF。 |
|
|
38
|
+
| **真实格式覆盖** | TXT、Markdown、DOCX、EPUB、TMX、CSV、SRT/VTT、PO、XLIFF 1.2/2.0/SDLXLIFF、HTML、JSON、XLSX、PPTX、RTF。 |
|
|
39
39
|
| **面向 Agent** | 七个工具共享当前文档和存储,Agent 可以与用户同时翻译。 |
|
|
40
40
|
|
|
41
41
|
## 快速开始
|
|
@@ -95,6 +95,17 @@ CAIT 为 DSH Web UI 和 DSH 桌面端增加一个 CAT 翻译工作台。它从
|
|
|
95
95
|
缩放系数。1600×900 面板约为 1.32×,2560×1440 面板为 1.8×;
|
|
96
96
|
窗口较矮时保持 1×,不会继续缩小。
|
|
97
97
|
|
|
98
|
+
### 预处理
|
|
99
|
+
|
|
100
|
+
导入的源文在切句之前会经过预处理阶段:
|
|
101
|
+
|
|
102
|
+
- 折叠重复空格与制表符、去掉行首缩进、合并连续空行。
|
|
103
|
+
- 移除零宽字符和多余的控制字符。
|
|
104
|
+
- 占位符 token(`{1}`、`{2}`…)、标点、大小写和段落顺序保持不变,
|
|
105
|
+
因此 XLIFF/HTML/EPUB 的内联标记仍可正确往返。
|
|
106
|
+
- 三个步骤可在 **设置 → 预处理** 中分别开关,并随其他设置一起持久化。
|
|
107
|
+
它们作用于新导入和 `createDocument` 调用,不会改写已有文档。
|
|
108
|
+
|
|
98
109
|
### MT 辅助
|
|
99
110
|
|
|
100
111
|
CAIT 不持有 endpoint 或 key,选择器完全来自 DSH:
|
|
@@ -114,15 +125,16 @@ provider/model/code/status,客户端只会收到 `MT_PROVIDER_FAILED`。
|
|
|
114
125
|
| 格式 | 导入 | 导出 | 说明 |
|
|
115
126
|
| --- | :---: | :---: | --- |
|
|
116
127
|
| TXT / Markdown | ✅ | ✅ | 按段落和句子切分 |
|
|
117
|
-
| CSV | ✅ | ✅ |
|
|
128
|
+
| CSV | ✅ | ✅ | 自动识别逗号、分号、制表符或竖线分隔;可通过表头名称或从 1 开始的列号指定源/目标列;现有双语导出 |
|
|
118
129
|
| DOCX | ✅ | ✅ | 正文段落;导入时排除表格块。导出会修改原包,保留样式、编号、图片、页眉、表格和版式。 |
|
|
130
|
+
| EPUB | ✅ | ✅ | 按 EPUB 3 spine 顺序读取 XHTML 文本块,内联标记保留为 token 并回写到保留的源包。不支持 DRM、固定版式和脚本化 EPUB。 |
|
|
119
131
|
| TMX 1.4 | ✅ | ✅ | 常见 `<tu>/<tuv>/<seg>` 子集;内联标记扁平化并警告 |
|
|
120
132
|
| SRT / WebVTT | ✅ | ✅ | 一个字幕 cue 对应一个句段;保留时间轴/设置/标识;保留语义标签;非法时间范围会拒绝 |
|
|
121
133
|
| PO | ✅ | ✅ | 支持上下文、复数形式、译者注释和废弃 `#~` 条目 |
|
|
122
134
|
| XLIFF 1.2 | ✅ | ✅ | 内联标签转换为 `{n}` token;缺少 token 时阻止确认 |
|
|
123
135
|
| XLIFF 2.0 | ✅ | ✅ | 基础 `<unit><segment><source>/<target>` 子集 |
|
|
124
136
|
| SDLXLIFF | ✅ | ✅ | 走基础 XLIFF 1.2 路径;SDL 专有扩展不会完整往返 |
|
|
125
|
-
| HTML | ✅ | ✅ |
|
|
137
|
+
| HTML | ✅ | ✅ | 保留文本块与内联标签;不重建文档级 CSS/版式 |
|
|
126
138
|
| JSON | ✅ | ✅ | 字符串路径子集;通过模板保留对象/数组结构;key 和数字不翻译 |
|
|
127
139
|
| XLSX | ✅ | ✅ | 第一个工作表;识别 `Source`/`Target` 表头或 A/B 列;导出为新的两列表格 |
|
|
128
140
|
| PPTX | ✅ | ✅* | 保留源格式导出;需要导入时保留的 `.pptx` 包。仅正文;备注/图表/SmartArt 不导入。 |
|
|
@@ -132,8 +144,25 @@ provider/model/code/status,客户端只会收到 `MT_PROVIDER_FAILED`。
|
|
|
132
144
|
而不是静默生成一个没有格式的演示文稿。
|
|
133
145
|
|
|
134
146
|
交换元数据(字幕时间轴、PO 上下文/复数/注释、XLIFF id 和内联 token 映射、
|
|
135
|
-
JSON 路径/模板、XLSX 行号、PPTX
|
|
136
|
-
|
|
147
|
+
JSON 路径/模板、XLSX 行号、PPTX 幻灯片/段落位置、EPUB spine href 和块序号)
|
|
148
|
+
会保存在文档/句段上,并随快照持久化。
|
|
149
|
+
|
|
150
|
+
### 不支持 PDF
|
|
151
|
+
|
|
152
|
+
CAIT 不导入 PDF,后续版本也不会加入 PDF 支持。PDF 是固定版式的打印格式,
|
|
153
|
+
没有逻辑段落、阅读顺序或内联标记;从中提取的文本会散落在绘图指令之间,
|
|
154
|
+
丢失标题、表格和内联强调,切出的句段对翻译记忆和 MT 都是很差的输入——
|
|
155
|
+
也就是说,PDF 极其不适合 AI 相关工作。
|
|
156
|
+
|
|
157
|
+
如果需要翻译 PDF 内容,请先转换成支持的格式,例如:
|
|
158
|
+
|
|
159
|
+
```sh
|
|
160
|
+
pandoc input.pdf -t docx -o output.docx # 或 -t html、-t markdown
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
也可以使用 Adobe Acrobat 的 **导出为 Word/HTML**、LibreOffice,或其他能生成
|
|
164
|
+
DOCX、HTML、EPUB 或纯文本的工具。扫描版 PDF 在转换前还需要 OCR;
|
|
165
|
+
CAIT 没有图片 OCR 阶段。
|
|
137
166
|
|
|
138
167
|
## 安装
|
|
139
168
|
|
|
@@ -149,7 +178,7 @@ CAIT 以 DSH bundle 的形式安装;发布的 npm 包名为 `dsh-cait`,插
|
|
|
149
178
|
plugin_manager install_bundle target: dsh-cait
|
|
150
179
|
```
|
|
151
180
|
|
|
152
|
-
需要固定版本时写 `dsh-cait@1.0.
|
|
181
|
+
需要固定版本时写 `dsh-cait@1.0.5`,需要最新版时写 `dsh-cait@latest`。管理器会解析 registry
|
|
153
182
|
上的包、应用 bundle patch 并激活插件,不需要手工在配置档里加行。
|
|
154
183
|
|
|
155
184
|
使用 CLI 管理的配置档:
|
|
@@ -214,7 +243,7 @@ dsh web --patch C:\absolute\path\to\dsh-CAIT\_dev\cait.patch.yml
|
|
|
214
243
|
```
|
|
215
244
|
|
|
216
245
|
快照保存文档、打开的标签页、TM、术语库、库、挂载关系和非敏感设置。
|
|
217
|
-
导入的 DOCX/PPTX 源包放在 `sources/` 下。
|
|
246
|
+
导入的 DOCX/PPTX/EPUB 源包放在 `sources/` 下。
|
|
218
247
|
|
|
219
248
|
界面内的**设置**保存在快照里,而不是上面的 YAML:源语言/目标语言、模糊阈值、
|
|
220
249
|
TM 返回条数、MT 路由/模型/温度,以及界面语言(`uiLang`:`auto` | `zh` | `en` |
|
|
@@ -286,6 +315,9 @@ cait/
|
|
|
286
315
|
│ ├─ persistence.js
|
|
287
316
|
│ ├─ import-export.js
|
|
288
317
|
│ ├─ formats.js # CSV/SRT/VTT/PO/XLIFF/HTML/JSON/RTF
|
|
318
|
+
│ ├─ html.js # 共享 HTML/XHTML 文本块扫描与回写
|
|
319
|
+
│ ├─ epub.js # EPUB 包读取 / spine 导入 / 回写导出
|
|
320
|
+
│ ├─ preprocess.js # 导入期源文预处理阶段
|
|
289
321
|
│ ├─ xlsx.js
|
|
290
322
|
│ ├─ pptx.js
|
|
291
323
|
│ ├─ segmenter.js
|
|
@@ -314,6 +346,8 @@ node --check client.js
|
|
|
314
346
|
node _dev/test-core.mjs
|
|
315
347
|
node _dev/test-imports.mjs
|
|
316
348
|
node _dev/test-formats.mjs
|
|
349
|
+
node _dev/test-epub.mjs
|
|
350
|
+
node _dev/test-preprocess.mjs
|
|
317
351
|
node _dev/test-second-tier.mjs
|
|
318
352
|
node _dev/test-docx-export.mjs
|
|
319
353
|
node _dev/test-api.mjs
|
|
@@ -328,7 +362,7 @@ node _dev/test-mt.mjs
|
|
|
328
362
|
|
|
329
363
|
导入/导出 fixture 为 `_dev/sample.docx`、`_dev/sample-table.docx` 和
|
|
330
364
|
`_dev/sample-format.docx`;可用对应的 `python _dev/make-*.py` 脚本重新生成。
|
|
331
|
-
|
|
365
|
+
15 套测试应全部通过。
|
|
332
366
|
|
|
333
367
|
### 发布
|
|
334
368
|
|
|
@@ -366,7 +400,10 @@ GitHub release 发布。
|
|
|
366
400
|
|
|
367
401
|
## 已知限制与路线图
|
|
368
402
|
|
|
369
|
-
-
|
|
403
|
+
- 不支持 PDF 导入;PDF 已被明确排除在范围外(见
|
|
404
|
+
[不支持 PDF](#不支持-pdf))。暂不支持图片 OCR。
|
|
405
|
+
- EPUB 导入只覆盖 spine 中的正文 XHTML 文本块;不支持 DRM、固定版式、
|
|
406
|
+
脚本化以及大量使用 MathML 的电子书。
|
|
370
407
|
- DOCX 导入会跳过表格、页眉、脚注、域、替代文本和修订删除内容。
|
|
371
408
|
DOCX 导出时这些区域保持源语言。
|
|
372
409
|
- DOCX/PPTX 中混合 run 的段落会继承第一个 run 的格式。
|
|
@@ -374,18 +411,19 @@ GitHub release 发布。
|
|
|
374
411
|
- XLSX 导入/导出是两列表格;不保留单元格样式、公式、合并单元格、图片和额外工作表。
|
|
375
412
|
- HTML/RTF 导出不往返原始样式;JSON 只翻译字符串值。
|
|
376
413
|
- TM 匹配是词法级的,不是语义级;没有词干、同义词或向量。
|
|
377
|
-
-
|
|
414
|
+
- 库重命名/删除和逐标签页挂载状态尚未实现。
|
|
378
415
|
- 工作台界面提供中文、English、日本語三种语言,可在设置中切换;README 提供英文、简体中文和日文三个版本,以英文版为准。
|
|
379
416
|
|
|
380
|
-
|
|
381
|
-
|
|
417
|
+
后续计划:通过多模态 DSH 路由支持图片/视觉输入、更完整的库管理、
|
|
418
|
+
保留样式的 XLSX 输出,以及 XLIFF `<alt-trans>` / 注释支持。
|
|
382
419
|
|
|
383
420
|
## 变更日志与版本
|
|
384
421
|
|
|
385
422
|
见 [CHANGELOG.md](CHANGELOG.md)。`v1.0.0` 是首个公开发布版本,`v1.0.1` 增加了
|
|
386
423
|
日语界面和界面内语言切换,`v1.0.2` 让「跟随 DSH 语言」真正跟随 DSH 的语言设置,
|
|
387
|
-
`v1.0.3` 把包发布到 npm,`v1.0.4` 起后续版本改由带 provenance
|
|
388
|
-
|
|
424
|
+
`v1.0.3` 把包发布到 npm,`v1.0.4` 起后续版本改由带 provenance 的发布流水线产出,
|
|
425
|
+
`v1.0.5` 增加 EPUB、导入预处理和 PDF 政策;项目在开发阶段使用 `0.1.0`,
|
|
426
|
+
发布到 GitHub 前统一改为 `1.0.0`。
|
|
389
427
|
|
|
390
428
|
> **License:** Apache License 2.0,见 [LICENSE](LICENSE)。再分发时需保留
|
|
391
429
|
> [NOTICE](NOTICE) 中的署名信息。
|
package/client/components.js
CHANGED
|
@@ -1064,7 +1064,7 @@
|
|
|
1064
1064
|
h('input', {
|
|
1065
1065
|
ref: inputRef,
|
|
1066
1066
|
type: 'file',
|
|
1067
|
-
accept: '.txt,.md,.markdown,.tmx,.docx,.csv,.srt,.vtt,.po,.pot,.xliff,.xlf,.sdlxliff,.html,.htm,.json,.rtf,.xlsx,.pptx',
|
|
1067
|
+
accept: '.txt,.md,.markdown,.tmx,.docx,.epub,.csv,.srt,.vtt,.po,.pot,.xliff,.xlf,.sdlxliff,.html,.htm,.json,.rtf,.xlsx,.pptx',
|
|
1068
1068
|
hidden: true,
|
|
1069
1069
|
onChange: (event) => pickFile(event.target.files?.[0]),
|
|
1070
1070
|
}),
|
|
@@ -1108,6 +1108,7 @@
|
|
|
1108
1108
|
['target-txt', t('modal.export.targetTxt'), t('modal.export.target'), 'download'],
|
|
1109
1109
|
['target-md', t('modal.export.targetMd'), t('modal.export.target'), 'download'],
|
|
1110
1110
|
['docx', t('modal.export.docx'), t('modal.export.docxGroup'), 'file'],
|
|
1111
|
+
['epub', t('modal.export.epub'), t('modal.export.epubGroup'), 'file'],
|
|
1111
1112
|
['srt', t('modal.export.srt'), t('modal.export.subtitleGroup'), 'file'],
|
|
1112
1113
|
['vtt', t('modal.export.vtt'), t('modal.export.subtitleGroup'), 'file'],
|
|
1113
1114
|
['po', t('modal.export.po'), t('modal.export.localizationGroup'), 'file'],
|
|
@@ -1147,6 +1148,11 @@
|
|
|
1147
1148
|
fuzzyThreshold: settings.fuzzyThreshold,
|
|
1148
1149
|
tmLimit: settings.tmLimit,
|
|
1149
1150
|
uiLang: settings.uiLang || 'auto',
|
|
1151
|
+
preprocess: {
|
|
1152
|
+
normalizeWhitespace: settings.preprocess?.normalizeWhitespace !== false,
|
|
1153
|
+
stripInvisible: settings.preprocess?.stripInvisible !== false,
|
|
1154
|
+
collapseBlankLines: settings.preprocess?.collapseBlankLines !== false,
|
|
1155
|
+
},
|
|
1150
1156
|
mt: {
|
|
1151
1157
|
provider: settings.mt.provider,
|
|
1152
1158
|
model: settings.mt.model,
|
|
@@ -1159,6 +1165,8 @@
|
|
|
1159
1165
|
const routeMissing = form.mt.provider !== 'mock' && !route
|
|
1160
1166
|
|
|
1161
1167
|
const setMt = (patch) => setForm((current) => ({ ...current, mt: { ...current.mt, ...patch } }))
|
|
1168
|
+
const setPre = (patch) =>
|
|
1169
|
+
setForm((current) => ({ ...current, preprocess: { ...current.preprocess, ...patch } }))
|
|
1162
1170
|
const selectProvider = (provider) => {
|
|
1163
1171
|
const nextRoute = routes.find((item) => item.id === provider)
|
|
1164
1172
|
setForm((current) => ({
|
|
@@ -1182,6 +1190,11 @@
|
|
|
1182
1190
|
fuzzyThreshold: Number(form.fuzzyThreshold),
|
|
1183
1191
|
tmLimit: Number(form.tmLimit),
|
|
1184
1192
|
uiLang: form.uiLang,
|
|
1193
|
+
preprocess: {
|
|
1194
|
+
normalizeWhitespace: Boolean(form.preprocess.normalizeWhitespace),
|
|
1195
|
+
stripInvisible: Boolean(form.preprocess.stripInvisible),
|
|
1196
|
+
collapseBlankLines: Boolean(form.preprocess.collapseBlankLines),
|
|
1197
|
+
},
|
|
1185
1198
|
mt: {
|
|
1186
1199
|
provider: form.mt.provider,
|
|
1187
1200
|
model: form.mt.model,
|
|
@@ -1248,6 +1261,24 @@
|
|
|
1248
1261
|
),
|
|
1249
1262
|
),
|
|
1250
1263
|
),
|
|
1264
|
+
h(
|
|
1265
|
+
'div',
|
|
1266
|
+
{ className: 'cait-settings-section' },
|
|
1267
|
+
h('h4', { className: 'cait-settings-title' }, t('modal.settings.preprocess')),
|
|
1268
|
+
h('p', { className: 'cait-mt-hint', style: { marginTop: 0 } }, t('modal.settings.preprocessHint')),
|
|
1269
|
+
['normalizeWhitespace', 'stripInvisible', 'collapseBlankLines'].map((key) =>
|
|
1270
|
+
h(
|
|
1271
|
+
'label',
|
|
1272
|
+
{ key, className: 'cait-checkline' },
|
|
1273
|
+
h('input', {
|
|
1274
|
+
type: 'checkbox',
|
|
1275
|
+
checked: Boolean(form.preprocess[key]),
|
|
1276
|
+
onChange: (event) => setPre({ [key]: event.target.checked }),
|
|
1277
|
+
}),
|
|
1278
|
+
t(`modal.settings.pre.${key}`),
|
|
1279
|
+
),
|
|
1280
|
+
),
|
|
1281
|
+
),
|
|
1251
1282
|
h(
|
|
1252
1283
|
'div',
|
|
1253
1284
|
{ className: 'cait-settings-section' },
|