google / mdbook-i18n-helpers

Translation support for mdbook. The plugins here give you a structured way to maintain a translated book.
Apache License 2.0
127 stars 25 forks source link

markdown file xgettext + gettext #92

Open friendlymatthew opened 11 months ago

friendlymatthew commented 11 months ago

fixes: https://github.com/google/mdbook-i18n-helpers/issues/68

markdown-gettext binary

You can execute this binary by the following:

markdown-gettext --dir=(directory path) --po=(lang.po path) --out=(output path)

or

markdown-gettext --f=(file path) --po=(lang.po path) --out=(output path)

_* Note: --dir or -f must be specified, -po is always required, and --out defaults to '/translated_mdfiles`

Suppose in comprehensive-rust I want to translate all md files in the concurrency section to japanese:

❯ markdown-gettext --dir=src/concurrency --po=po/ja.po --out=concurrency_ja_md_files

❯ cd concurrency_ja_md_files

❯ ls 
channels.md       scoped-threads.md send-sync.md      shared_state.md   threads.md

threads.md

Screen Shot 2023-09-28 at 2 27 56 PM

__

markdown-xgettext binary

You can execute this binary by the following:

markdown-xgettext (input.md) (output.po) --lang=(language) --out=(output path)

or

 echo `> ..md content..` | markdown-xgettext - output.po --lang=(language) --out=(output path)

* Note: If --lang is not specified, the .pot default to English.

Example command:

echo '> # Exercises

To practice your Async Rust skills, we have again two exercises for you:

* Dining philosophers: we already saw this problem in the morning. This time
  you are going to implement it with Async Rust.

* A Broadcast Chat Application: this is a larger project that allows you
  experiment with more advanced Async Rust features.

<details>

After looking at the exercises, you can look at the [solutions] provided.

[solutions]: solutions-afternoon.md

</details>
' | markdown-xgettext - output.po --lang=fr

output.po

Screen Shot 2023-09-27 at 5 03 15 PM