Skip to content

Commit 0a1c3f9

Browse files
dyoomgeisler
authored andcommitted
Add support for skipping translation groups
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.
1 parent 540ba32 commit 0a1c3f9

File tree

4 files changed

+294
-15
lines changed

4 files changed

+294
-15
lines changed

Cargo.lock

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ mdbook = { version = "0.4.25", default-features = false }
1515
polib = "0.2.0"
1616
pulldown-cmark = { version = "0.9.2", default-features = false }
1717
pulldown-cmark-to-cmark = "10.0.4"
18+
regex = "1.9.4"
1819
semver = "1.0.16"
1920
serde_json = "1.0.91"
2021

USAGE.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,34 @@ Please see the [`publish.yml`] workflow in the Comprehensive Rust 🦀 repositor
182182

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

185+
## Marking Sections to be Skipped for Translation
186+
187+
A block can be marked to be skipped for translation by prepending a special HTML
188+
comment `<!--- mdbook-xgettext:skip -->` to it.
189+
190+
For example:
191+
192+
````markdown
193+
The following code block should not be translated.
194+
195+
<!--- mdbook-xgettext:skip -->
196+
197+
```
198+
fn hello() {
199+
println!("Hello world!");
200+
}
201+
```
202+
203+
Itemized list:
204+
205+
- A should be translated.
206+
207+
<!--- mdbook-xgettext:skip -->
208+
209+
- B should be skipped.
210+
- C should be translated.
211+
````
212+
185213
## Normalizing Existing PO Files
186214

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

0 commit comments

Comments
 (0)