Skip to content

Update some translations #5

Update some translations

Update some translations #5

name: Sync translations to other languages
on:
push:
paths:
- "en-US/**.json"
branches:
- "**/stable"
workflow_dispatch:
jobs:
sync_translations:
name: Sync translations
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "14"
- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm install
- name: Install jq (JSON processor)
uses: dcarbone/install-jq-action@main
- name: Copy new JSON files to other languages
run: |
for lang_dir in $(find . -mindepth 1 -maxdepth 1 -type d -name "*-*" | grep -E '[a-z]{2}-[A-Z]{2}'); do
lang=$(basename "$lang_dir")
find en-US -type f -name "*.json" | while read file; do
new_file="${file/en-US/$lang}"
if [ ! -f "$new_file" ]; then
mkdir -p "$(dirname "$new_file")"
cp "$file" "$new_file"
echo "Created $new_file in $lang"
fi
done
done
- name: Commit changes
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
rm -f package-lock.json
git add .
if ! git diff-index --quiet HEAD; then
git commit -m "Add new translation files for other languages"
else
echo "No changes to commit"
exit 0
fi
- name: Create a pull request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Add new translation files for other languages"
branch: "auto/sync-translations-${{ github.ref_name }}"
title: "Sync translations in ${{ github.ref_name }}"
body: "This PR adds new translation files for the branch **${{ github.ref_name }}**."
assignees: ilxlodev
reviewers: ilxlodev
labels: syncronization, blocked
base: ${{ github.ref_name }}