mdbook-i18n-helpers icon indicating copy to clipboard operation
mdbook-i18n-helpers copied to clipboard

Add tool which can build translations for all available languages

Open mgeisler opened this issue 2 years ago • 4 comments

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) where mdbook-i18n build would do the looping seen above.

mgeisler avatar Apr 04 '23 16:04 mgeisler

Maybe related with upstream mdbook?

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

simonsan avatar Apr 05 '23 15:04 simonsan

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 build for 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.

mgeisler avatar Apr 06 '23 10:04 mgeisler

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 avatar Sep 26 '23 07:09 mgeisler

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.

mgeisler avatar Sep 26 '23 07:09 mgeisler