Skip to content

Update scripts to support the publication of the Chinese patterns translation #513

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

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: Determine book language
run: |
[[ "$GITHUB_REF_NAME" =~ ^book-ja.*$ ]] && book_language="ja" || book_language="en"
[[ "$GITHUB_REF_NAME" =~ ^book-.*$ ]] && book_language=${GITHUB_REF_NAME:5:2} || book_language="en"
echo "BOOK_LANGUAGE=$book_language" >> $GITHUB_ENV

- name: Generate ToC
Expand Down
8 changes: 5 additions & 3 deletions book/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ The `/book` folder contains generator scripts and extra content required to crea
- `/book/en/explore-patterns.md` - Shows the mind map of all patterns. Allows readers to link to the mind map directly.
- patterns content:
- The English patterns are in `/patterns`
- The translated patterns (e.g. for Japanese) are in `/translation/ja`
- The translated patterns are in `/translation/<YOUR_LANGUAGE>`[^1]

The book is generated in multiple languages.

The descriptions above are for the English book. You find the English content in `/book/en`.

For other languages (e.g. for Japanese), the content is mirrored and translated to folders like `/book/ja`.
For other languages the content is mirrored and translated to folders like `/book/<YOUR_LANGUAGE>`[^1].

For more on the translation process see [these translation instructions](../translation/README.md).

Expand All @@ -45,7 +45,7 @@ The book is generated in multiple languages.
Depending on which **branch** a change is merged into, a different book is generated:

* changes merged to `main` branch: triggers the book generation for the **English** book.
* changes merged to `book-ja` branch: triggers the book generation for the **Japanese** book.
* 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.

## Objectives of the book

Expand All @@ -64,3 +64,5 @@ There are a couple of good reasons to publish the InnerSource patterns as a gitb
[InnerSourcePatterns]: https://github.com/InnerSourceCommons/InnerSourcePatterns
[book_production]: https://patterns.innersourcecommons.org
[book_staging]: https://innersourcecommons.gitbook.io/innersource-patterns-staging/

[^1]: Replace `<YOUR_LANGUAGE>` with the 2-letter language code for your language.
12 changes: 7 additions & 5 deletions book/scripts/generate_toc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,16 @@ def generate_patterns_overview(patterns)
puts "Generating ToC for language: #{BOOK_LANGUAGE}"

## Files to be used for the different languages
if (BOOK_LANGUAGE == "ja")
TOC_TEMPLATE_FILE = "../ja/toc_template.md"
TOC_FILE = "../ja/toc.md"
PATTERNS = Dir["../../translation/ja/patterns/*.md"]
else
## Note: the folder structure for the patterns is slightly different for 'en' than it is for the other languages,
## hence this slightly complicated logic here.
if (BOOK_LANGUAGE == "en")
TOC_TEMPLATE_FILE = "../en/toc_template.md"
TOC_FILE = "../en/toc.md"
PATTERNS = Dir["../../patterns/2-structured/*.md","../../patterns/2-structured/project-setup/*.md", "../../patterns/3-validated/*.md"]
else
TOC_TEMPLATE_FILE = "../#{BOOK_LANGUAGE}/toc_template.md"
TOC_FILE = "../#{BOOK_LANGUAGE}/toc.md"
PATTERNS = Dir["../../translation/#{BOOK_LANGUAGE}/patterns/*.md"]
end

# Generate list of patterns and sort them by name
Expand Down