2022-08-08 00:26:40 +00:00
|
|
|
---
|
2022-03-11 05:26:53 +00:00
|
|
|
name: localize
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [nightly]
|
2022-04-18 18:53:28 +00:00
|
|
|
paths: # prevents workflow from running unless these files change
|
2022-04-24 00:50:42 +00:00
|
|
|
- '.github/workflows/localize.yml'
|
2022-08-08 03:37:57 +00:00
|
|
|
- 'src/**'
|
2022-04-18 18:53:28 +00:00
|
|
|
- 'locale/sunshine.po'
|
2022-03-11 05:26:53 +00:00
|
|
|
workflow_dispatch:
|
|
|
|
|
2022-04-29 23:02:10 +00:00
|
|
|
env:
|
|
|
|
file: ./locale/sunshine.po
|
|
|
|
|
2022-03-11 05:26:53 +00:00
|
|
|
jobs:
|
|
|
|
localize:
|
|
|
|
name: Update Localization
|
|
|
|
runs-on: ubuntu-latest
|
2022-04-18 18:53:28 +00:00
|
|
|
|
2022-03-11 05:26:53 +00:00
|
|
|
steps:
|
2022-08-08 00:26:40 +00:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
2022-03-11 05:26:53 +00:00
|
|
|
|
2022-08-08 00:26:40 +00:00
|
|
|
- name: Install Python 3.9
|
|
|
|
uses: actions/setup-python@v4 # https://github.com/actions/setup-python
|
|
|
|
with:
|
|
|
|
python-version: '3.9'
|
2022-03-11 05:26:53 +00:00
|
|
|
|
2022-08-08 00:26:40 +00:00
|
|
|
- name: Set up Python 3.9 Dependencies
|
|
|
|
run: |
|
|
|
|
cd ./scripts
|
|
|
|
python -m pip install --upgrade pip setuptools
|
|
|
|
python -m pip install -r requirements.txt
|
2022-03-11 05:26:53 +00:00
|
|
|
|
2022-08-08 00:26:40 +00:00
|
|
|
- name: Set up xgettext
|
|
|
|
run: |
|
|
|
|
sudo apt-get update -y && \
|
|
|
|
sudo apt-get --reinstall install -y \
|
|
|
|
gettext
|
2022-03-11 05:26:53 +00:00
|
|
|
|
2022-08-08 00:26:40 +00:00
|
|
|
- name: Update Strings
|
|
|
|
run: |
|
|
|
|
# first, try to remove existing file as xgettext does not remove unused translations
|
|
|
|
if [ -f "${{ env.file }}" ];
|
|
|
|
then
|
|
|
|
rm ${{ env.file }}
|
|
|
|
echo "new_file=false" >> $GITHUB_ENV
|
|
|
|
else
|
|
|
|
echo "new_file=true" >> $GITHUB_ENV
|
|
|
|
fi
|
2022-04-29 23:02:10 +00:00
|
|
|
|
2022-08-08 00:26:40 +00:00
|
|
|
# extract the new strings
|
|
|
|
python ./scripts/_locale.py --extract
|
2022-03-11 05:26:53 +00:00
|
|
|
|
2022-08-08 00:26:40 +00:00
|
|
|
- name: git diff
|
|
|
|
if: ${{ env.new_file == 'false' }}
|
|
|
|
run: |
|
|
|
|
# disable the pager
|
|
|
|
git config --global pager.diff false
|
2022-04-24 00:50:42 +00:00
|
|
|
|
2022-08-08 00:26:40 +00:00
|
|
|
# print the git diff
|
|
|
|
git diff locale/sunshine.po
|
2022-04-18 18:53:28 +00:00
|
|
|
|
2022-10-23 17:21:00 +00:00
|
|
|
# set the variable with minimal output, replacing `\t` with ` `
|
|
|
|
OUTPUT=$(git diff --numstat locale/sunshine.po | sed -e "s#\t# #g")
|
2022-08-08 00:26:40 +00:00
|
|
|
echo "git_diff=${OUTPUT}" >> $GITHUB_ENV
|
2022-04-18 18:53:28 +00:00
|
|
|
|
2022-08-08 00:26:40 +00:00
|
|
|
- name: git reset
|
|
|
|
# only run if a single line changed (date/time) and file already existed
|
2022-10-23 17:21:00 +00:00
|
|
|
if: ${{ env.git_diff == '1 1 locale/sunshine.po' && env.new_file == 'false' }}
|
2022-08-08 00:26:40 +00:00
|
|
|
run: |
|
|
|
|
git reset --hard
|
2022-04-18 18:53:28 +00:00
|
|
|
|
2022-10-23 17:21:00 +00:00
|
|
|
- name: Get current date
|
|
|
|
id: date
|
|
|
|
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
|
|
|
|
|
2022-08-08 00:26:40 +00:00
|
|
|
- name: Create/Update Pull Request
|
2023-05-06 13:18:00 +00:00
|
|
|
uses: peter-evans/create-pull-request@v5
|
2022-08-08 00:26:40 +00:00
|
|
|
with:
|
|
|
|
add-paths: |
|
|
|
|
locale/*.po
|
|
|
|
token: ${{ secrets.GH_BOT_TOKEN }} # must trigger PR tests
|
|
|
|
commit-message: New localization template
|
|
|
|
branch: localize/update
|
|
|
|
delete-branch: true
|
|
|
|
base: nightly
|
|
|
|
title: New Babel Updates
|
|
|
|
body: |
|
|
|
|
Update report
|
2022-10-23 17:21:00 +00:00
|
|
|
- Updated ${{ steps.date.outputs.date }}
|
2022-08-08 00:26:40 +00:00
|
|
|
- Auto-generated by [create-pull-request][1]
|
2022-04-18 18:53:28 +00:00
|
|
|
|
2022-08-08 00:26:40 +00:00
|
|
|
[1]: https://github.com/peter-evans/create-pull-request
|
|
|
|
labels: |
|
|
|
|
babel
|
|
|
|
l10n
|