Skip to content

Commit

Permalink
mdbook-i18n-helpers test
Browse files Browse the repository at this point in the history
  • Loading branch information
RadxaYuntian committed Oct 11, 2023
1 parent 395e251 commit f859c24
Show file tree
Hide file tree
Showing 7 changed files with 1,129 additions and 4 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,33 @@ jobs:
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: 'latest'
- name: Install mdbook-admonish
- name: Install mdbook plugins
shell: bash
run: |
cargo install mdbook-admonish
cargo install mdbook-i18n-helpers
- name: Build
run: mdbook build
run: |
mdbook build
for po_lang in zh-CN
do
POT_CREATION_DATE=$(grep --max-count 1 '^"POT-Creation-Date:' po/$po_lang.po | sed -E 's/".*: (.*)\\n"/\1/')
if [[ $POT_CREATION_DATE == "" ]]; then
POT_CREATION_DATE=now
fi
echo "::group::Building $po_lang translation as of $POT_CREATION_DATE"
rm -r docs/
git restore --source "$(git rev-list -n 1 --before "$POT_CREATION_DATE" @)" docs/
# Set language and adjust site URL. Clear the redirects
# since they are in sync with the source files, not the
# translation.
MDBOOK_BOOK__LANGUAGE=$po_lang \
MDBOOK_OUTPUT__HTML__SITE_URL=/bsp/$po_lang/ \
MDBOOK_OUTPUT__HTML__REDIRECT='{}' \
mdbook build -d book/$po_lang
echo "::endgroup::"
done
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
Expand Down
11 changes: 10 additions & 1 deletion book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@ multilingual = true
src = "docs"
title = "bsp"

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

[output.html]
git-repository-url = "https://github.com/radxa-repo/bsp/tree/main"
edit-url-template = "https://github.com/radxa-repo/bsp/edit/main/{path}"
additional-css = ["./theme/css/mdbook-admonish.css"]
additional-css = [
"./theme/css/mdbook-admonish.css",
"./theme/css/language-picker.css",
]

[preprocessor]

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

[preprocessor.admonish]
command = "mdbook-admonish"
assets_version = "2.0.2" # do not edit: managed by `mdbook-admonish install`
2 changes: 1 addition & 1 deletion docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
---
# Low-level troubleshooting
- [Firmware management](firmware/management.md)
- [`setup.sh` usage](firmware/setup_sh.md)
- [setup.sh usage](firmware/setup_sh.md)
---
# Common use cases
- [Running from GitHub Workflows](gh_workflows.md)
Expand Down
Loading

0 comments on commit f859c24

Please sign in to comment.