mdbook-i18n-helpers
mdbook-i18n-helpers copied to clipboard
Add tool which can build translations for all available languages
The mdbook-gettext preprocessor translates a book into a single language. To translate your book into all available languages, you need to build a look yourself. An example of this can be found in the publish.yml GitHub action for Comprehensive Rust 🦀:
- name: Build all translations
run: |
for po_lang in ${{ env.LANGUAGES }}; do
echo "::group::Building $po_lang translation"
MDBOOK_BOOK__LANGUAGE=$po_lang \
MDBOOK_OUTPUT__HTML__SITE_URL=/comprehensive-rust/$po_lang/ \
mdbook build -d book/$po_lang
echo "::endgroup::"
done
We should make this easier somehow. Idea:
- Build a small command line tool (perhaps called
mdbook-i18n) wheremdbook-i18n buildwould do the looping seen above.
Maybe related with upstream mdbook?
https://github.com/rust-lang/mdBook/pull/2029
Maybe related with upstream
mdbook? rust-lang/mdBook#2029
Yes, partially: @jooyunghan also works in Android and made the PR to simplify our translation infrastructure.
Here, I was thinking of making a small stand-alone tool which can do all the looping we need to implement translations. It would
- call
MDBOOK_BOOK__LANGUAGE=xx mdbook buildfor all languages. - it would generate the language picker drop-down and inject this into the generated HTML (or theme or similar).
I think that approach would be more flexible than trying to teach mdbook all this.
Hey @sakex, I assigned this to you since this is basically what you're doing in #84. So you should update the PR to say "Fixes #13" so it will close this one automatically.
Note that I've made implementing this issue a bit more complicated with https://github.com/google/comprehensive-rust/pull/1243: you'll need to use Git library to update the src/ folder to the right version.
On the other hand, this feature makes the backend here much more useful: instead of replacing a small for-loop, it can now replace more complex logic! This makes this renderer more relevant and useful for everybody.