Skip to content

German translation #359

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

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
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
183 changes: 91 additions & 92 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,95 +25,94 @@ jobs:
- name: Test code snippets
run: mdbook test

# TODO: Activate when first translation is available
# i18n-helpers:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3

# - name: Install Gettext
# run: sudo apt install gettext

# - name: Setup Rust cache
# uses: ./.github/workflows/setup-rust-cache

# - name: Install mdbook
# uses: ./.github/workflows/install-mdbook

# - name: Generate po/messages.pot
# run: mdbook build -d po
# env:
# MDBOOK_OUTPUT: '{"xgettext": {"pot-file": "messages.pot"}}'

# - name: Test messages.pot
# run: msgfmt --statistics -o /dev/null po/messages.pot

# - name: Expand includes without translation
# run: mdbook build -d expanded
# env:
# MDBOOK_OUTPUT: '{"markdown": {}}'

# - name: Expand includes with no-op translation
# run: mdbook build -d no-op
# env:
# MDBOOK_OUTPUT: '{"markdown": {}}'
# MDBOOK_PREPROCESSOR__GETTEXT__PO_FILE: po/messages.pot

# - name: Compare no translation to no-op translation
# run: diff --color=always --unified --recursive expanded no-op

# find-translations:
# runs-on: ubuntu-latest
# outputs:
# languages: ${{ steps.find-translations.outputs.languages }}
# steps:
# - name: Checkout
# uses: actions/checkout@v3

# - name: Find translations
# id: find-translations
# shell: python
# run: |
# import os, json, pathlib
# languages = [p.stem for p in pathlib.Path("po").iterdir() if p.suffix == ".po"]
# github_output = open(os.environ["GITHUB_OUTPUT"], "a")
# github_output.write("languages=")
# json.dump(sorted(languages), github_output)

# translations:
# runs-on: ubuntu-latest
# needs:
# - find-translations
# strategy:
# matrix:
# language: ${{ fromJSON(needs.find-translations.outputs.languages) }}
# env:
# MDBOOK_BOOK__LANGUAGE: ${{ matrix.language }}
# steps:
# - name: Checkout
# uses: actions/checkout@v3

# - name: Install Gettext
# run: sudo apt install gettext

# - name: Setup Rust cache
# uses: ./.github/workflows/setup-rust-cache

# - name: Install mdbook
# uses: ./.github/workflows/install-mdbook

# - name: Test ${{ matrix.language }} translation
# run: msgfmt --statistics -o /dev/null po/${{ matrix.language }}.po

# - name: Build book with ${{ matrix.language }} translation
# run: mdbook build

# - name: Upload ${{ matrix.language }} translation
# uses: actions/upload-artifact@v3
# with:
# name: rust-design-patterns-${{ matrix.language }}
# path: book/

# - name: Test code snippets with ${{ matrix.language }} translation
# run: mdbook test
i18n-helpers:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Gettext
run: sudo apt install gettext

- name: Setup Rust cache
uses: ./.github/workflows/setup-rust-cache

- name: Install mdbook
uses: ./.github/workflows/install-mdbook

- name: Generate po/messages.pot
run: mdbook build -d po
env:
MDBOOK_OUTPUT: '{"xgettext": {"pot-file": "messages.pot"}}'

- name: Test messages.pot
run: msgfmt --statistics -o /dev/null po/messages.pot

- name: Expand includes without translation
run: mdbook build -d expanded
env:
MDBOOK_OUTPUT: '{"markdown": {}}'

- name: Expand includes with no-op translation
run: mdbook build -d no-op
env:
MDBOOK_OUTPUT: '{"markdown": {}}'
MDBOOK_PREPROCESSOR__GETTEXT__PO_FILE: po/messages.pot

- name: Compare no translation to no-op translation
run: diff --color=always --unified --recursive expanded no-op

find-translations:
runs-on: ubuntu-latest
outputs:
languages: ${{ steps.find-translations.outputs.languages }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Find translations
id: find-translations
shell: python
run: |
import os, json, pathlib
languages = [p.stem for p in pathlib.Path("po").iterdir() if p.suffix == ".po"]
github_output = open(os.environ["GITHUB_OUTPUT"], "a")
github_output.write("languages=")
json.dump(sorted(languages), github_output)

translations:
runs-on: ubuntu-latest
needs:
- find-translations
strategy:
matrix:
language: ${{ fromJSON(needs.find-translations.outputs.languages) }}
env:
MDBOOK_BOOK__LANGUAGE: ${{ matrix.language }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Gettext
run: sudo apt install gettext

- name: Setup Rust cache
uses: ./.github/workflows/setup-rust-cache

- name: Install mdbook
uses: ./.github/workflows/install-mdbook

- name: Test ${{ matrix.language }} translation
run: msgfmt --statistics -o /dev/null po/${{ matrix.language }}.po

- name: Build book with ${{ matrix.language }} translation
run: mdbook build

- name: Upload ${{ matrix.language }} translation
uses: actions/upload-artifact@v3
with:
name: rust-design-patterns-${{ matrix.language }}
path: book/

- name: Test code snippets with ${{ matrix.language }} translation
run: mdbook test
33 changes: 20 additions & 13 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ name: Deploy mdBook sites to GH Pages

on:
push:
branches: ["main"]
# TODO: Change before merge into main
# branches: ["main"]
branches:
- main
- translation-de

workflow_dispatch:

permissions:
Expand All @@ -19,9 +24,12 @@ env:
CARGO_TERM_COLOR: always
# TODO: Update the language picker in index.hbs to link new languages.
# TODO: As long as https://github.com/google/mdbook-i18n-helpers/issues/12 is not implemented, yet.
# TODO: Activate when first translation is available
# These are the languages in addition to 'en', which is the main language
# LANGUAGES: xx
# de linked, due to being partly reviewed
# es not linked, due to being mostly unreviewed
# it not linked, due to being mostly unreviewed
# pt-BR not linked, due to being mostly unreviewed
LANGUAGES: de es it pt-BR

jobs:
publish:
Expand All @@ -42,16 +50,15 @@ jobs:
- name: Build course in English
run: mdbook build -d book

# TODO: Activate when first translation is available
# - 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=/patterns/$po_lang/ \
# mdbook build -d book/$po_lang
# echo "::endgroup::"
# done
- 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=/patterns/$po_lang/ \
mdbook build -d book/$po_lang
echo "::endgroup::"
done

- name: Setup Pages
id: pages
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Generated output of mdbook
/book
.DS_Store
po/*.mo
2 changes: 1 addition & 1 deletion language-picker.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#language-list {
left: auto;
right: 10px;
right: 9em;
}

#language-list a {
Expand Down
Loading