Skip to content

Commit 863dbd8

Browse files
committed
(CI) updating locale on push
1 parent f2a1aa3 commit 863dbd8

File tree

4 files changed

+106
-16
lines changed

4 files changed

+106
-16
lines changed

.github/scripts/update_locale.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
# ------------------------------------------------------------------------------
3+
# pgRouting Scripts
4+
# Copyright(c) pgRouting Contributors
5+
#
6+
# Update the locale files
7+
# ------------------------------------------------------------------------------
8+
9+
10+
11+
DIR=$(git rev-parse --show-toplevel)
12+
13+
pushd "${DIR}" > /dev/null || exit 1
14+
15+
pushd build > /dev/null || exit 1
16+
cmake -DLOCALE=ON ..
17+
18+
make locale
19+
popd > /dev/null || exit 1
20+
21+
# List all the files that needs to be committed in build/doc/locale_changes.txt
22+
awk '/^Update|^Create/{print $2}' build/doc/locale_changes.txt > build/doc/locale_changes_po.txt # .po files
23+
cp build/doc/locale_changes_po.txt build/doc/locale_changes_po_pot.txt
24+
perl -pe 's/(.*)en\/LC_MESSAGES(.*)/$1pot$2t/' < build/doc/locale_changes_po.txt >> build/doc/locale_changes_po_pot.txt # .pot files
25+
26+
# List all the files that needs to be committed in build/presentation/locale_changes.txt
27+
awk '/^Update|^Create/{print $2}' build/presentation/locale_changes.txt > build/presentation/locale_changes_po.txt # .po files
28+
cp build/presentation/locale_changes_po.txt build/presentation/locale_changes_po_pot.txt
29+
perl -pe 's/(.*)en\/LC_MESSAGES(.*)/$1pot$2t/' < build/presentation/locale_changes_po.txt >> build/presentation/locale_changes_po_pot.txt # .pot files
30+
31+
# Remove obsolete entries #~ from .po files
32+
bash tools/transifex/remove_obsolete_entries.sh
33+
34+
# Remove duplicate string locations
35+
perl -i -ne 'print unless (defined($prev) && ($_ eq $prev)); $prev=$_' locale/pot/*.pot
36+
37+
while read -r f; do git add "$f"; done < build/doc/locale_changes_po_pot.txt
38+
while read -r f; do git add "$f"; done < build/presentation/locale_changes_po_pot.txt
39+
40+
popd > /dev/null || exit 1

.github/workflows/deploy-pages.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,3 @@ jobs:
5050
with:
5151
github_token: ${{ secrets.GITHUB_TOKEN }}
5252
publish_dir: build/_build/html
53-
54-
- name: Update locale
55-
if: github.ref == 'refs/heads/master'
56-
run: |
57-
mkdir -p build
58-
bash tools/transifex/update_locale.sh
59-
60-
# Add the files, commit and push
61-
for line in `cat build/doc/locale_changes_po_pot.txt`; do git add "$line"; done
62-
git diff --staged --quiet || git commit -m "Update locale: commit ${{ env.GIT_HASH }}"
63-
git fetch origin master
64-
git restore . # Remove the unstaged changes before rebasing
65-
git rebase origin/master
66-
git push origin master

.github/workflows/locale-update.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Update Locale
2+
3+
# This action runs:
4+
# - When this file changes
5+
# - When changes on documentation (doc)
6+
# - When is triggered manually
7+
8+
on:
9+
workflow_dispatch:
10+
push:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
update-locale:
17+
permissions:
18+
contents: write # for Git to git push
19+
name: Update Locale
20+
runs-on: ubuntu-22.04
21+
22+
strategy:
23+
fail-fast: false
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 1
30+
31+
- name: Install apt packages
32+
run: |
33+
sudo apt-get install cmake cpanminus
34+
sudo cpanm Text::SimpleTable::AutoWidth
35+
36+
- name: Setup Python
37+
uses: actions/setup-python@v4
38+
with:
39+
python-version: '3.x'
40+
41+
- name: Install dependencies
42+
run: |
43+
python -m pip install --upgrade pip
44+
python -m pip install -r ./requirements.txt
45+
46+
- name: Extract branch name and commit hash
47+
run: |
48+
branch=${GITHUB_REF#refs/heads/}
49+
git_hash=$(git rev-parse --short "$GITHUB_SHA")
50+
echo "GIT_HASH=$git_hash" >> $GITHUB_ENV
51+
52+
- name: Initialize mandatory git config
53+
run: |
54+
git config user.name "github-actions[bot]"
55+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
56+
57+
- name: Update locale
58+
run: |
59+
mkdir build
60+
bash .github/scripts/update_locale.sh
61+
62+
# Add the files, commit and push
63+
git diff --staged --quiet || git commit -m "Locale update: for commit ${{ env.GIT_HASH }}"
64+
git restore . # Remove the unstaged changes before rebasing
65+
git push

presentation/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ if (LOCALE)
5050
"${CMAKE_CURRENT_BINARY_DIR}/revealjs"
5151
"${CMAKE_SOURCE_DIR}/locale/pot"
5252

53-
COMMAND sphinx-intl update
54-
-d ${CMAKE_SOURCE_DIR}/locale -l en >> locale_changes.txt
53+
COMMAND sphinx-intl update -d ${CMAKE_SOURCE_DIR}/locale -l en >> locale_changes.txt
5554

5655
#COMMAND sphinx-intl update-txconfig-resources
5756
#--locale-dir ${CMAKE_SOURCE_DIR}/locale

0 commit comments

Comments
 (0)