Checker for translated mdbook
console
$ cargo install mdbook-transcheck
The following command checks whether src
and tgt
are synchronized.
console
$ mdbook-transcheck src tgt
src
is the source directory of original mdbook.
tgt
is the source directory of translated mdbook.
The following command applies the differences between src
and tgt
to tgt
.
console
$ mdbook-transcheck --fix src tgt
The configuration file is transcheck.toml
, which is put at the repository root.
toml
enable_code_comment_tweak = true
code_comment_header = "# "
| Key | Value | Default | Description |
| ------------------------- | ----------- | ------- | ------------------------------------------------------------------------------------------------------------------------------- |
| enablecodecommenttweak | true, false | false | Match code comment without code_comment_header
|
| codecommentheader | [String] | "# "
| |
| similarthreshold | [Float] | 0.5 | If the ratio which the original and translated lines are matched exceeds similar_threshold
, the line is judged as modified. |
```console $ mdbook-transcheck ./testcase/original ./testcase/translated
Error: target path is not found source path: ./testcase/original/missingfile.md target path: ./testcase/translated/missingfile.md
Error: source line has been modified source --> ./testcase/original/mismatch_lines.md:5 | 5 | This is an orange. | ^^ ^^ |
target --> ./testcase/translated/mismatch_lines.md:11 | 11 | This is an apple. | ^^^ |
Error: lines has been inserted to the source file source --> ./testcase/original/mismatchlines.md:2 | 2 | Orange | = hint: The lines should be inserted at ./testcase/translated/mismatchlines.md:2
Error: lines has been removed from the source file target --> ./testcase/translated/mismatch_lines.md:4 | 4 | Lemon | ```
The translated markdown should follow some rules.
<!--
and -->
markdown
Apple
Orange
Peach
markdown
<!--
Apple
Orange
Peach
-->
りんご
オレンジ
桃
The following is NG because <!-- Apple
and Peach -->
are not matched with original lines.
markdown
<!-- Apple
Orange
Peach -->
りんご
オレンジ
桃
markdown
```rust
// comment
let a = b; // comment
```
markdown
```rust
// comment
// コメント
let a = b; // comment
// コメント
```
You can use #
to hide the original comment.
enable_code_comment_tweak
should be true
, and code_comment_header
should be #
.
`markdown
rust
// コメント let a = b; // comment // コメント ``` ````
You can use # //
to hide the original code and comment.
enable_code_comment_tweak
should be true
, and code_comment_header
should be # //
.
`markdown
rust
// コメント
let a = b; // コメント ``` ````