diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml index 98870b2cb..02846a63c 100644 --- a/.github/workflows/book.yml +++ b/.github/workflows/book.yml @@ -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 diff --git a/book/README.md b/book/README.md index ce3ccff0d..c07cd375a 100644 --- a/book/README.md +++ b/book/README.md @@ -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/`[^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/`[^1]. For more on the translation process see [these translation instructions](../translation/README.md). @@ -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-`[^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 @@ -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 `` with the 2-letter language code for your language. diff --git a/book/scripts/generate_toc.rb b/book/scripts/generate_toc.rb index 391e03310..49a608c2f 100644 --- a/book/scripts/generate_toc.rb +++ b/book/scripts/generate_toc.rb @@ -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