Skip to content

Commit

Permalink
Add language picker for docs (ordinals#2403)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph committed Aug 30, 2023
1 parent 24231be commit 7bb33ea
Show file tree
Hide file tree
Showing 6 changed files with 433 additions and 4 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ defaults:

env:
RUSTFLAGS: --deny warnings
LANGUAGES:

jobs:
docs:
Expand All @@ -34,7 +35,18 @@ jobs:
chmod +x mdbook-linkcheck
pwd >> $GITHUB_PATH
- run: mdbook build docs
- name: Build docs
run: mdbook build docs -d build

- name: Build all translations for docs
run: |
for lang in ${{ env.LANGUAGES }}; do
echo "::group::Building $lang translation"
MDBOOK_BOOK__LANGUAGE=$lang \
mdbook build docs -d build/$lang
mv docs/build/$lang/html docs/build/html/$lang
echo "::endgroup::"
done
- name: Deploy Pages
uses: peaceiris/actions-gh-pages@v3
Expand All @@ -43,6 +55,7 @@ jobs:
github_token: ${{secrets.GITHUB_TOKEN}}
publish_branch: gh-pages
publish_dir: docs/build/html

lint:
runs-on: ubuntu-latest

Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,15 @@ Release x.y.z
- Update dependencies
- Update database schema version
```

Translations
------------

To translate [the docs](https://docs.ordinals.com) we use this
[mdBook i18n helper](https://github.com/google/mdbook-i18n-helpers).
So read through their [usage guide](https://github.com/google/mdbook-i18n-helpers/blob/main/USAGE.md)
to see the structure that translations should follow.

There are some other things to watch out for but feel free to just start a
translation and open a PR. A maintainer will then help you integrate it into our
build system.
5 changes: 5 additions & 0 deletions docs/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ src = "src"
[build]
build-dir = "build"
create-missing = false
extra-watch-dirs = ["po"]

[output.html]
cname = "docs.ordinals.com"
default-theme = "coal"
git-repository-url = "https://github.com/ordinals/ord"
preferred-dark-theme = "coal"
additional-css = ["language-picker.css"]

[output.linkcheck]

[preprocessor.gettext]
after = ["links"]
8 changes: 8 additions & 0 deletions docs/language-picker.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#language-list {
left: auto;
right: 10px;
}

#language-list a {
color: inherit;
}
Loading

0 comments on commit 7bb33ea

Please sign in to comment.