Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mdbook-i18n-helpers to support translations #356

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 31 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
branches: [ staging, trying, master ]
pull_request:

permissions:
contents: read
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-20.04
Expand All @@ -21,25 +26,9 @@ jobs:
- name: Put pip binary directory into path
run: echo "~/.local/bin" >> $GITHUB_PATH

- name: Cache Cargo installed binaries
uses: actions/cache@v1
id: cache-cargo
with:
path: ~/cargo-bin
key: cache-cargo
- name: Install mdbook
if: steps.cache-cargo.outputs.cache-hit != 'true'
uses: actions-rs/[email protected]
- uses: moonrepo/setup-rust@v0
with:
crate: mdbook
version: latest
- name: Copy mdbook to cache directory
if: steps.cache-cargo.outputs.cache-hit != 'true'
run: |
mkdir ~/cargo-bin
cp ~/.cargo/bin/mdbook ~/cargo-bin
- name: Put new cargo binary directory into path
run: echo "~/cargo-bin" >> $GITHUB_PATH
bins: mdbook, mdbook-i18n-helpers

- name: Build book
run: mdbook build
Expand All @@ -48,10 +37,28 @@ jobs:
- name: Check links
run: linkchecker book

- name: Deploy book
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: peaceiris/actions-gh-pages@v3
- name: Build translations
# Expand the list of langauges in the for loop as needed.
# Update the language picker in theme/index.hbs when a
# language is complete enough to be found by users.
run: |
for po_lang in da; do
echo "::group::Building $po_lang translation"
MDBOOK_BOOK__LANGUAGE=$po_lang \
MDBOOK_OUTPUT__HTML__SITE_URL=/book/$po_lang/ \
mdbook build -d book/$po_lang
echo "::endgroup::"
done

- name: Setup Pages
uses: actions/configure-pages@v2

- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: book
force_orphan: true
path: book

- name: Deploy to GitHub Pages
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
id: deployment
uses: actions/deploy-pages@v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
book
po/messages.pot
6 changes: 6 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@ multilingual = false
src = "src"
title = "The Embedded Rust Book"

[build]
extra-watch-dirs = ["po"]

[preprocessor.gettext]
after = ["links"]

[output.html]
git-repository-url = "https://github.com/rust-embedded/book"
Loading