Skip to content

Commit 6728eca

Browse files
spierrmarting
authored andcommitted
Host translations in gitbook, using monorepo approach (InnerSourceCommons#578)
* Remove the main gitbook yaml file. Need to be sure that config is picked up from subfolders. * Change config of the en book * Change config of the ja book * Change config of the zh book * Generate the TOCs for all books in a GHA matrix build * Change commit messsage in book.yaml workflow run to make clear which file was changed and why * Improve documentation
1 parent 478a225 commit 6728eca

File tree

9 files changed

+36
-39
lines changed

9 files changed

+36
-39
lines changed

.gitbook.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/book.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ name: Gitbook Generation
33
on:
44
push:
55
branches:
6-
- "main"
7-
- "book-*"
6+
- main
7+
pull_request:
8+
branches:
9+
- main
810

911
jobs:
1012
gitbook-generation:
1113
runs-on: ubuntu-latest
1214

15+
strategy:
16+
matrix:
17+
language: [en, ja, zh]
18+
1319
steps:
1420
- uses: actions/checkout@v3
1521
with:
@@ -21,22 +27,13 @@ jobs:
2127
working-directory: 'book/scripts/'
2228
bundler-cache: true
2329

24-
- name: Determine book language
25-
run: |
26-
[[ "$GITHUB_REF_NAME" =~ ^book-.*$ ]] && book_language=${GITHUB_REF_NAME:5:2} || book_language="en"
27-
echo "BOOK_LANGUAGE=$book_language" >> $GITHUB_ENV
28-
2930
- name: Generate ToC
3031
run: |
3132
cd book/scripts/
32-
ruby generate_toc.rb $BOOK_LANGUAGE
33-
echo "Generated book for: $BOOK_LANGUAGE" >> $GITHUB_STEP_SUMMARY
34-
35-
- name: Copy .gitbook.yml to root
36-
run: |
37-
cp book/$BOOK_LANGUAGE/.gitbook.yaml .
33+
ruby generate_toc.rb ${{ matrix.language }}
34+
echo "Generated book for: ${{ matrix.language }}" >> $GITHUB_STEP_SUMMARY
3835
39-
- name: Commit updated files for the book
36+
- name: Commit updated toc.md for the book
4037
uses: stefanzweifel/git-auto-commit-action@v4
4138
with:
42-
commit_message: Writing updated files for the book
39+
commit_message: Writing updated toc.md for the ${{ matrix.language }} book

book/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ We use the [gitbook.com](https://www.gitbook.com) service to host our book.
2020

2121
The `/book` folder contains generator scripts and extra content required to create the gitbook.
2222

23-
- `.github/workflows/book.yml` - A GitHub Action that triggers scripts to generate the book.
24-
- `/book/scripts/generate_toc.rb` - Generates the table of contents (ToC) for the book. It takes patterns of maturity **Structured** and **Validated**, extracts title and patlet, and injects this info into `/book/en/toc_template.md`. The output is written to `/book/en/toc.md`. The ToC is what you see on the left-hand-side menu in the gitbook.
25-
- `/book/en/.gitbook.yaml` - Holds basic configuration for the gitbook service. This file is copied to the root of the repo, if the English book is generated.
23+
- `.github/workflows/book.yml` - A GitHub Action that triggers `generate_toc.rb`.
24+
- `/book/scripts/generate_toc.rb` - Generates the table of contents (ToC) for the book. It takes patterns of maturity **Structured** and **Validated**, extracts title and patlet, and injects this info into `/book/en/toc_template.md`. The output is written to `/book/en/toc.md`. The ToC is what you see in the menu on the left in the gitbook.
25+
- `/book/en/.gitbook.yaml` - Holds basic configuration for the gitbook service.
2626
- `/book/en/introduction.md` - The introduction to our book. This is what the reader sees first when they open the book. *Note:* The current content is based on [README.md](../README.md).
2727
- `/book/en/contribute.md` - Explains how to contribute to this book.
2828
- `/book/en/explore-patterns.md` - Shows the mind map of all patterns. Allows readers to link to the mind map directly.
@@ -42,10 +42,13 @@ For more on the translation process see [these translation instructions](../tran
4242

4343
The book is generated in multiple languages.
4444

45-
Depending on which **branch** a change is merged into, a different book is generated:
45+
gitbook takes care of the markdown to HTML rendering for us.
46+
To do so, we need to provide a full list of all patterns that should be dipslayed in the book.
4647

47-
* changes merged to `main` branch: triggers the book generation for the **English** book.
48-
* changes merged to `book-<YOUR_LANGUAGE>`[^1] branch: triggers the book generation for the book in the given language e.g. `book-jp` for the **Japanese** book.
48+
As the list of patterns grows over time, we generate the list automatically using `/book/scripts/generate_toc.rb`.
49+
The script is triggered by the [.github/workflows/book.yml](https://github.com/InnerSourceCommons/InnerSourcePatterns/blob/main/.github/workflows/book.yml) workflow, which contains a hard-coded list of all languages for which we need to generate `toc.md` files.
50+
51+
If a new language is added, you need to modify [this line](https://github.com/InnerSourceCommons/InnerSourcePatterns/blob/monorepo-test/.github/workflows/book.yml#L17) in `.github/workflows/book.yml` and add the 2-letter language code of the language that you are adding.
4952

5053
## Objectives of the book
5154

book/en/.gitbook.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
root : ./
22

33
structure:
4-
readme: book/en/introduction.md
5-
summary: book/en/toc.md
4+
readme: introduction.md
5+
summary: toc.md

book/en/introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
![InnerSource Patterns book](innersource-patterns-book-cover.jpg)
44

55
{% hint style="info" %}
6-
You are reading an early release of the InnerSource Patterns book and may still find broken links, spelling mistakes, or other errors.
7-
Please help us to fix them to produce the best book possible :). Learn how to [contribute to this book](contribute.md).
6+
You can help us to create the best possible book about InnerSource Patterns :).
7+
Learn how to [contribute to this book](contribute.md).
88
{% endhint %}
99

1010
Welcome to the **InnerSource Patterns Book**.

book/ja/.gitbook.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
root : ./
22

33
structure:
4-
readme: book/ja/introduction.md
5-
summary: book/ja/toc.md
4+
readme: introduction.md
5+
summary: toc.md
66

book/ja/toc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Instead edit toc_template.md
3939
* [基本原則ガイダンスの文書化](../../translation/ja/patterns/document-your-guiding-principles.md) - 「オープンソースのベストプラクティスを組織内に適用する」という通常のインナーソースの説明は、オープンソースのバックグラウンドがない人々にはうまく機能しません。 解決策として、インナーソースの最も重要な原則を文書化し広く公開しましょう。
4040
* [実験として始める](../../translation/ja/patterns/start-as-experiment.md) - インナーソースイニシアチブを期間限定の実験として開始し、インナーソースに慣れていないマネージャーがイニシアチブを承認およびサポートしやすくします。
4141
* [成熟度モデル](../../translation/ja/patterns/maturity-model.md) - チームはインナーソースを採用し始めました。このプラクティスは、複数の部門に広がっています。しかし、インナーソースプロジェクトを構成する概念への理解は様々です。解決策は、チームがセルフチェックを経て、まだ気づいていないパターンやプラクティスを発見できるよう、成熟度モデルを提供することです。
42+
* [持続可能な成長のためのエクステンション](../../translation/ja/patterns/extensions-for-sustainable-growth.md) - インナーソースプロジェクトは多くのコントリビューションを受けており、メンテナンスが難しくなっています。メンテナは、プロジェクトのコア部分から離れた拡張機構を提供することで、最小のコストとメンテナンスオーバーヘッドでプロジェクトの能力をスケールアップすることを可能にします。
4243
* [正式なコミュニティリーダー](../../translation/ja/patterns/dedicated-community-leader.md) - インナーソースの取り組みを成功させるために、コミュニケーションとテクニカルの両方のスキルを持つ人をコミュニティのリーダーとして選ぶ。
4344

4445
## 付録<a id="appendix"></a>

book/zh/.gitbook.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
root : ./
22

33
structure:
4-
readme: book/zh/introduction.md
5-
summary: book/zh/toc.md
4+
readme: introduction.md
5+
summary: toc.md

translation/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ Please note that this document contains recommendations, aimed at removing barri
2222
- Please make your changes to the respective `.md` file.
2323
- Once you are ready, send us a Pull Request.
2424

25-
### Translating a new InnerSource Patterns
25+
### Adding a new InnerSource Pattern to an Existing Translation
2626

2727
- Copy the pattern that you want to translate from `/patterns/2-structured/<file>.md` to `/translation/<YOUR_LANGUAGE>/patterns/<file>.md`.[^1] Make sure to keep the file name the same.
2828
- Then start your translation in that new file.
2929
- Once you are ready, send us a Pull Request.
3030

31-
### Starting the Translation of a New Language
31+
### Starting the Translation of an Entirely New Language
3232

3333
That is awesome! We welcome your passion. When implementing InnerSource practices in your region, there can be language barriers. There is great value in getting people in your organization to understand InnerSource in their own language.
3434

3535
Before starting a new translation please talk to us in Slack (in the `#innersource-patterns` channel). Alternatively open an issue on this GitHub repo to start an async conversation about your translation project.
3636

37-
The translation should begin by creating a `book-<YOUR_LANGUAGE>` branch to work on.[^1]
38-
e.g. `book-jp` is used for the Japanese translation.
37+
The translation should begin by creating a new `translation-<YOUR_LANGUAGE>` branch to work on.[^1]
38+
e.g. `translation-de` would be used for the German translation.
3939

4040
There are a few things you should prepare before starting a translation project.
4141

@@ -56,7 +56,8 @@ In particular, for special terms, such as "Trusted Committer", please review not
5656
The patterns books is published in multiple languages, including English, Japanese and Chinese (as of August/2023).
5757
Find the full list of available languages in the [patterns books](https://patterns.innersourcecommons.org/).
5858

59-
Trusted Committers in this repository will also be onboarded during the translation process.
59+
When publishing an entirely new language to our book, we also like to add at least one of the translators as a Trusted Committer to the project.
60+
They will then get notified on any fixes/additions to the translation in the future, and can greatly help us by providing reviews.
6061

6162
When you complete a translation under `/translation/<YOUR_LANGUAGE>/`, a GitHub Actions pipeline will run to generate the output for publication in the gitbook. The process is described in detail in [/book/README.md](/book/README.md).
6263

0 commit comments

Comments
 (0)