diff --git a/.github/workflows/add-lang.yml b/.github/workflows/add-lang.yml index 0a9a12f11..7d092523f 100644 --- a/.github/workflows/add-lang.yml +++ b/.github/workflows/add-lang.yml @@ -17,34 +17,36 @@ jobs: ISSUE_TITLE: ${{ github.event.issue.title }} ISSUE_NUM: ${{ github.event.issue.number }} run: | - NEW_LANG=$(sed 's/.*\[\([^]]*\)].*/\1/' <<< "$ISSUE_TITLE") - if [[ $NEW_LANG =~ ^[a-z]{2}(_[A-Z]{2})?$ ]]; then - echo "new_lang=$NEW_LANG" >> $GITHUB_ENV + LANG_CODE=$(sed 's/.*\[\([^]]*\)].*/\1/' <<< "$ISSUE_TITLE") + FULL_LANG=$(sed 's/.*<\([^>]*\)>.*/\1/' <<< "$ISSUE_TITLE") + if [[ $LANG_CODE =~ ^[a-z]{2}(-[A-Z]{2})?$ && $ISSUE_TITLE =~ <[^>]+> ]]; then + echo "lang_code=$LANG_CODE" >> $GITHUB_ENV + echo "full_lang=$FULL_LANG" >> $GITHUB_ENV echo "issue_num=$ISSUE_NUM" >> $GITHUB_ENV else - echo Error: language code in wrong format. + echo Error: language name/code in wrong format. exit 1 fi # Check out repo: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: next-release # Check if language has been added previously. - name: Check if language is already present run: | - if [ -d "_translator-files/po/${{ env.new_lang }}" ] ; then - echo Error: The language [${{ env.new_lang }}] seems to already exist. + if [ -d "_translator-files/po/${{ env.lang_code }}" ] ; then + echo Error: The language [${{ env.lang_code }}] seems to already exist. exit 1 else - echo Language: [${{ env.new_lang }}] not detected. Proceeding to add [${{ env.new_lang }}]. + echo Language: [${{ env.lang_code }}] seems to be new as no Language: [${{ env.lang_code }}] was found. Proceeding to add [${{ env.lang_code }}]. fi # Check po4a cache. If CACHE_HIT: true, retrieve the cache. # If not, install po4a and its dependencies and copy them all to a folder (~/po4a/) to be cached: - name: Check for po4a cache - uses: actions/cache@v3 + uses: actions/cache@v4 id: cache-po4a with: path: "~/po4a" @@ -60,23 +62,23 @@ jobs: # Push changes to 'next-release': - name: Push changes to repo - uses: EndBug/add-and-commit@v7 + uses: EndBug/add-and-commit@v9 with: branch: next-release default_author: github_actions - message: 'AUTO: Add new language: (${{ env.new_lang }}) #${{ env.issue_num }}' + message: 'AUTO: Add new language: ${{ env.lang_code }}: ${{ env.full_lang }} #${{ env.issue_num }}' # Add comment to issue informing of the creation of the language files: - name: Add comment to issue - uses: peter-evans/create-or-update-comment@v1 + uses: peter-evans/create-or-update-comment@v4 with: issue-number: ${{ env.issue_num }} body: | - - The .po files have been created for **${{ env.new_lang }}** and are now available on [Weblate](https://hosted.weblate.org/projects/jamulus/#languages). If you prefer not to use Weblate and intend to submit translations via a Pull Request, your language files can be found on the `next-release` branch in `_translator-files/po/${{ env.new_lang }}/`. + - The .po files have been created for **${{ env.full_lang }}** and are now available on [Weblate](https://hosted.weblate.org/projects/jamulus/#languages). If you prefer not to use Weblate and intend to submit translations via a Pull Request, your language files can be found on the `next-release` branch in `_translator-files/po/${{ env.lang_code }}/`. - Please consult [this README file](https://github.com/jamulussoftware/jamuluswebsite/tree/next-release/_translator-files#readme) for more information on the translation process. # Create target translated files. Never pushed to the repo. - - name: Create translated docs and stats + - name: Create translated docs run: ./_po4a-tools/po4a-create-all-targets.sh # Build site diff --git a/_po4a-tools/po4a-add-language.sh b/_po4a-tools/po4a-add-language.sh index 24e3e42d9..f7c91cb7f 100755 --- a/_po4a-tools/po4a-add-language.sh +++ b/_po4a-tools/po4a-add-language.sh @@ -8,38 +8,40 @@ SCRIPT_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) cd "$SCRIPT_DIR" # Create and populate .po file folder -mkdir ../_translator-files/po/$new_lang +mkdir ../_translator-files/po/$lang_code echo '' -echo .po file folder created for "$new_lang" -echo Creating .po files for "$new_lang" +echo .po file folder created for "$lang_code" +echo Creating .po files for "$full_lang" ./po4a-update-templates.sh # Go to root directory cd ../ -# Create symlinks for 1-index.html file -ln -s -r ./wiki/$new_lang/1-index.html ./1-$new_lang-index.html +# Create symlinks for 1-index.md file +ln -s -r ./wiki/$lang_code/1-index.md ./1-$lang_code-index.md if [ $(echo $?) == 0 ] ; then echo '' - echo 1-"$new_lang"-index.html symlink created for "$new_lang" in / + echo 1-"$lang_code"-index.md symlink created for "$full_lang" in / else - echo Error creating 1-"$new_lang"-index.html symlink in / + echo Error creating 1-"$lang_code"-index.md symlink in / exit 1 fi -# Add new language to array in _config.yml -sed -i "s/\(\[\"en\",\)/\1 \"$new_lang\",/" _config.yml +# Add new language to _config.yml +sed -i "s/\(\[\"en\",\)/\1 \"$lang_code\",/" _config.yml +sed -i "/^language_names:/a\ $lang_code: $full_lang" _config.yml + if [ $(echo $?) == 0 ] ; then - echo "$new_lang" added to language array in _config.yml + echo "$lang_code" added to _config.yml else - echo Error adding "$new_lang" to language array in _config.yml + echo Error adding "$lang_code" to _config.yml exit 1 fi # Create images folder for new language -if [ ! -d "./assets/img/$new_lang-screenshots" ] ; then - cp -frp ./assets/img/en-screenshots -T ./assets/img/$new_lang-screenshots - echo Screenshots created for "$new_lang" in ./assets/img/"$new_lang"-screenshots/ +if [ ! -d "./assets/img/$lang_code-screenshots" ] ; then + cp -frp ./assets/img/en-screenshots -T ./assets/img/$lang_code-screenshots + echo Screenshots created for "$full_lang" in ./assets/img/"$lang_code"-screenshots/ else - echo Error: screenshots folder for "$new_lang" seems to already exist + echo Error: screenshots folder for "$full_lang" seems to already exist fi