Skip to content

Commit fd8a8ed

Browse files
committed
Begin of refactoring for translations
1 parent 7606bef commit fd8a8ed

161 files changed

Lines changed: 20295 additions & 23897 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
MDBOOK_VERSION=0.4.28
2+
MDBOOK_I8N_HELPERS_VERSION=0.1.0

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
# Check for updates every Monday
6+
schedule:
7+
interval: "weekly"
8+
open-pull-requests-limit: 10

.github/workflows/build.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
mdbook:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
19+
- name: Install mdbook
20+
uses: ./.github/workflows/install-mdbook
21+
22+
- name: Test code snippets
23+
run: mdbook test
24+
25+
i18n-helpers:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v3
30+
31+
- name: Install Gettext
32+
run: sudo apt install gettext
33+
34+
- name: Install mdbook
35+
uses: ./.github/workflows/install-mdbook
36+
37+
- name: Generate po/messages.pot
38+
run: mdbook build -d po
39+
env:
40+
MDBOOK_OUTPUT: '{"xgettext": {"pot-file": "messages.pot"}}'
41+
42+
- name: Test messages.pot
43+
run: msgfmt --statistics -o /dev/null po/messages.pot
44+
45+
- name: Expand includes without translation
46+
run: mdbook build -d expanded
47+
env:
48+
MDBOOK_OUTPUT: '{"markdown": {}}'
49+
50+
- name: Expand includes with no-op translation
51+
run: mdbook build -d no-op
52+
env:
53+
MDBOOK_OUTPUT: '{"markdown": {}}'
54+
MDBOOK_PREPROCESSOR__GETTEXT__PO_FILE: po/messages.pot
55+
56+
- name: Compare no translation to no-op translation
57+
run: diff --color=always --unified --recursive expanded no-op
58+
59+
find-translations:
60+
runs-on: ubuntu-latest
61+
outputs:
62+
languages: ${{ steps.find-translations.outputs.languages }}
63+
steps:
64+
- name: Checkout
65+
uses: actions/checkout@v3
66+
67+
- name: Find translations
68+
id: find-translations
69+
shell: python
70+
run: |
71+
import os, json, pathlib
72+
languages = [p.stem for p in pathlib.Path("po").iterdir() if p.suffix == ".po"]
73+
github_output = open(os.environ["GITHUB_OUTPUT"], "a")
74+
github_output.write("languages=")
75+
json.dump(sorted(languages), github_output)
76+
77+
translations:
78+
runs-on: ubuntu-latest
79+
needs:
80+
- find-translations
81+
strategy:
82+
matrix:
83+
language: ${{ fromJSON(needs.find-translations.outputs.languages) }}
84+
env:
85+
MDBOOK_BOOK__LANGUAGE: ${{ matrix.language }}
86+
steps:
87+
- name: Checkout
88+
uses: actions/checkout@v3
89+
90+
- name: Install Gettext
91+
run: sudo apt install gettext
92+
93+
- name: Install mdbook
94+
uses: ./.github/workflows/install-mdbook
95+
96+
- name: Test ${{ matrix.language }} translation
97+
run: msgfmt --statistics -o /dev/null po/${{ matrix.language }}.po
98+
99+
- name: Build book with ${{ matrix.language }} translation
100+
run: mdbook build
101+
102+
- name: Upload ${{ matrix.language }} translation
103+
uses: actions/upload-artifact@v3
104+
with:
105+
name: comprehensive-rust-${{ matrix.language }}
106+
path: book/
107+
108+
- name: Test code snippets with ${{ matrix.language }} translation
109+
run: mdbook test

.github/workflows/gh-pages.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: github pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Read .env
15+
id: mdbook-version
16+
run: |
17+
. ./.env
18+
echo "::set-output name=MDBOOK_VERSION::${MDBOOK_VERSION}"
19+
20+
- name: Setup mdbook
21+
uses: peaceiris/actions-mdbook@v1
22+
with:
23+
mdbook-version: '${{ steps.mdbook-version.outputs.MDBOOK_VERSION }}'
24+
25+
- run: mdbook build
26+
27+
- name: Deploy
28+
uses: peaceiris/actions-gh-pages@v3
29+
with:
30+
github_token: ${{ secrets.GITHUB_TOKEN }}
31+
publish_dir: ./book
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Install mdbook and dependencies
2+
3+
description: Install the mdbook with the dependencies we need.
4+
5+
runs:
6+
using: composite
7+
steps:
8+
- name: Read mdbook version from .env
9+
id: mdbook-version
10+
run: |
11+
. ./.env
12+
echo "::set-output name=MDBOOK_VERSION::${MDBOOK_VERSION}"
13+
14+
- name: Read mdbook-i8n-helpers version from .env
15+
id: mdbook-i8n-helpers-version
16+
run: |
17+
. ./.env
18+
echo "::set-output name=MDBOOK_I8N_HELPERS_VERSION::${MDBOOK_I8N_HELPERS_VERSION}"
19+
20+
# The --locked flag is important for reproducible builds. It also
21+
# avoids breakage due to skews between mdbook and mdbook-svgbob.
22+
- name: Install mdbook
23+
run: cargo install mdbook --locked --version '${{ steps.mdbook-version.outputs.MDBOOK_VERSION }}'
24+
shell: bash
25+
26+
- name: Install i18n-helpers
27+
run: cargo install mdbook-i18n-helpers --locked '${{ steps.mdbook-i8n-helpers-version.outputs.MDBOOK_I8N_HELPERS_VERSION }}'
28+
shell: bash

.github/workflows/lint.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
markdown-lint:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Lint all original files recursively
14+
uses: avto-dev/markdown-lint@v1
15+
with:
16+
config: ".markdownlint.yaml"
17+
args: "**/*.md"

.github/workflows/publish.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
# Allow one concurrent deployment
15+
concurrency:
16+
group: pages
17+
cancel-in-progress: true
18+
19+
env:
20+
CARGO_TERM_COLOR: always
21+
# Update the language picker in index.hbs to link new languages.
22+
LANGUAGES: da pt-BR ko
23+
24+
jobs:
25+
publish:
26+
environment:
27+
name: github-pages
28+
url: ${{ steps.deployment.outputs.page_url }}
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v3
33+
34+
- name: Install mdbook
35+
uses: ./.github/workflows/install-mdbook
36+
37+
- name: Build course in English
38+
run: mdbook build -d book
39+
40+
- name: Build all translations
41+
run: |
42+
for po_lang in ${{ env.LANGUAGES }}; do
43+
echo "::group::Building $po_lang translation"
44+
MDBOOK_BOOK__LANGUAGE=$po_lang \
45+
MDBOOK_OUTPUT__HTML__SITE_URL=/patterns/$po_lang/ \
46+
mdbook build -d book/$po_lang
47+
echo "::endgroup::"
48+
done
49+
50+
- name: Setup Pages
51+
uses: actions/configure-pages@v2
52+
53+
- name: Upload artifact
54+
uses: actions/upload-pages-artifact@v1
55+
with:
56+
path: book
57+
58+
- name: Deploy to GitHub Pages
59+
id: deployment
60+
uses: actions/deploy-pages@v1
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "^(http|https)://crates.io/"
5+
}
6+
]
7+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Check Markdown links
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
markdown-link-check:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: gaurav-nelson/github-action-markdown-link-check@v1
14+
with:
15+
use-verbose-mode: 'yes'
16+
use-quiet-mode: 'yes'
17+
config-file: '.github/workflows/url-check-config.json'
18+
check-modified-files-only: 'yes'
19+
base-branch: 'main'
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Check Markdown links Periodically
2+
3+
on:
4+
schedule:
5+
# Run everyday at 0:00 AM
6+
- cron: "0 0 * * *"
7+
8+
jobs:
9+
markdown-link-check:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: gaurav-nelson/github-action-markdown-link-check@v1
14+
with:
15+
use-verbose-mode: 'yes'
16+
use-quiet-mode: 'yes'
17+
config-file: '.github/workflows/url-check-config.json'
18+
base-branch: 'main'

0 commit comments

Comments
 (0)