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
133 stars 25 forks source link

Add tool which can build translations for all available languages #13

Open mgeisler opened 1 year ago

mgeisler commented 1 year ago

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:

simonsan commented 1 year ago

Maybe related with upstream mdbook?

https://github.com/rust-lang/mdBook/pull/2029

mgeisler commented 1 year ago

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

I think that approach would be more flexible than trying to teach mdbook all this.

mgeisler commented 1 year ago

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.

mgeisler commented 1 year ago

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.