Skip to content

Commit

Permalink
Add support for skipping translation groups
Browse files Browse the repository at this point in the history
This adds support for adding a comment of the form: `<!--
mdbook-xgettext: skip -->`. This will cause the system to skip the
next message group that would otherwise be translated.

It adds a dependency to the regex crate to match for the comment skip
pattern.

Tests were added, including tests that cover some odd situations
involving inline HTML, which unfortunately appear to be due to
pulldown-cmark/pulldown-cmark#712.
  • Loading branch information
dyoo authored and mgeisler committed Sep 5, 2023
1 parent 540ba32 commit 0a1c3f9
Show file tree
Hide file tree
Showing 4 changed files with 294 additions and 15 deletions.
13 changes: 7 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mdbook = { version = "0.4.25", default-features = false }
polib = "0.2.0"
pulldown-cmark = { version = "0.9.2", default-features = false }
pulldown-cmark-to-cmark = "10.0.4"
regex = "1.9.4"
semver = "1.0.16"
serde_json = "1.0.91"

Expand Down
28 changes: 28 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,34 @@ Please see the [`publish.yml`] workflow in the Comprehensive Rust 🦀 repositor

[`publish.yml`]: https://github.com/google/comprehensive-rust/blob/main/.github/workflows/publish.yml

## Marking Sections to be Skipped for Translation

A block can be marked to be skipped for translation by prepending a special HTML
comment `<!--- mdbook-xgettext:skip -->` to it.

For example:

````markdown
The following code block should not be translated.

<!--- mdbook-xgettext:skip -->

```
fn hello() {
println!("Hello world!");
}
```

Itemized list:

- A should be translated.

<!--- mdbook-xgettext:skip -->

- B should be skipped.
- C should be translated.
````

## Normalizing Existing PO Files

When mdbook-i18n-helpers change, the generated PO files change as well. This can
Expand Down
Loading

0 comments on commit 0a1c3f9

Please sign in to comment.