Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add updated translation source files #26

5 changes: 4 additions & 1 deletion .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
name: Lint Commit Messages

on:
- pull_request
# - pull_request
push:
branches:
- dummy

jobs:
commitlint:
Expand Down
269 changes: 141 additions & 128 deletions .github/workflows/extract-translation-source-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
name: Extract Translation Source Files

on:
workflow_dispatch: # by request
schedule:
- cron: '0 0 * * *' # every day at midnight
- pull_request

jobs:
setup-branch:
Expand Down Expand Up @@ -39,9 +37,19 @@ jobs:
max-parallel: 1
matrix:
repo:
- course-discovery
- credentials
- RecommenderXBlock
# - course-discovery
# - credentials
# - ['completion', 'shadinaif/FC-0012-OEP-58']
# - ['edx-ace', 'shadinaif/FC-0012-OEP-58']
# - ['edx-bulk-grades', 'shadinaif/FC-0012-OEP-58']
# - ['edx-ora2', 'shadinaif/FC-0012-OEP-58']
# - ['edx-proctoring', 'shadinaif/FC-0012-OEP-58']
# - ['DoneXBlock', 'shadinaif/FC-0012-OEP-58']
# - ['RecommenderXBlock', 'shadinaif/FC-0012-OEP-58']
- ['xblock-adventure', 'shadinaif/FC-0012-OEP-58']
# - ['xblock-drag-and-drop-v2', 'shadinaif/FC-0012-OEP-58']
# - ['xblock-submit-and-compare', 'shadinaif/FC-0012-OEP-58']
# - ['xblock-qualtrics-survey', 'shadinaif/FC-0012-OEP-58']
runs-on: ubuntu-latest
continue-on-error: true
needs: [setup-branch]
Expand All @@ -58,11 +66,12 @@ jobs:
run: sudo apt install -y gettext

# Clones the repository
- name: clone openedx/${{ matrix.repo }}
- name: clone Zeit-Labs/${{ matrix.repo[0] }}
uses: actions/checkout@v3
with:
repository: openedx/${{ matrix.repo }}
path: translations/${{ matrix.repo }}
repository: Zeit-Labs/${{ matrix.repo[0] }}
ref: ${{ matrix.repo[1] }}
path: translations/${{ matrix.repo[0] }}

# Sets up Python
- name: setup python
Expand All @@ -77,7 +86,7 @@ jobs:
# Extracts the translation source files
- name: extract translation source files
run: |
cd translations/${{ matrix.repo }}
cd translations/${{ matrix.repo[0] }}
make extract_translations

# git adds only the translation source files, found in conf/locale/en
Expand All @@ -87,18 +96,18 @@ jobs:
# set identity
git config --global user.email "translations-bot@openedx.org"
git config --global user.name "edx-transifex-bot"
# Change directory to translations/${{ matrix.repo }}
cd translations/${{ matrix.repo }}
# Change directory to translations/${{ matrix.repo[0] }}
cd translations/${{ matrix.repo[0] }}
# finds the directory containing the english locale usually located in
# */*/conf/locale/en
EN_DIR=$(find . -type d -regex ".+conf\/locale\/en$")
# remove translations/${{ matrix.repo }}/.git so we don't commit a submodule
# remove translations/${{ matrix.repo[0] }}/.git so we don't commit a submodule
rm -rf .git
# finds the django.po and djangojs.po files generated by make
# extract_translations into EN_DIR and adds them
DJANGO_PATH=$(find $EN_DIR -name 'django.po')
DJANGOJS_PATH=$(find $EN_DIR -name 'djangojs.po')
git add $DJANGO_PATH $DJANGOJS_PATH -v
git add $DJANGO_PATH $DJANGOJS_PATH -f -v
# Check the git statuses of the translation source files
echo "GIT_STATUS=$(git status $DJANGO_PATH $DJANGOJS_PATH -s | wc -l)" >> $GITHUB_ENV

Expand All @@ -107,112 +116,115 @@ jobs:
if: "${{ env.GIT_STATUS > 0 }}"
run: |
# commit the changes
git commit -m "chore: add extracted translation source files from ${{ matrix.repo }}"
git commit -m "chore: add extracted translation source files from ${{ matrix.repo[0] }}"
# push changes to branch
git push

js-translations:
strategy:
# using max-parallel to avoid git push/pull issues when running in parallel
max-parallel: 1
matrix:
# repos missing extract_translations target in makefile:
# * frontend-app-admin-portal
# * frontend-app-publisher
# * frontend-platform
# * frontend-enterprise?
# * frontend-app-learner-portal-enterprise
# * frontend-build?
# * frontend-app-learner-portal-programs
# * frontend-component-cookie-policy-banner
# * frontend-app-programs-dashboard
# repos with errors running extract_translations
# * frontend-template-application
repo:
- frontend-app-account
- frontend-app-authn
- frontend-app-communications
- frontend-app-course-authoring
- frontend-app-discussions
- frontend-app-ecommerce
- frontend-app-enterprise-public-catalog
- frontend-app-gradebook
- frontend-app-learner-dashboard
- frontend-app-learner-record
- frontend-app-learning
- frontend-app-library-authoring
- frontend-app-ora-grading
- frontend-app-payment
- frontend-app-profile
- frontend-app-program-console
- frontend-app-support-tools
- frontend-component-footer
- frontend-component-header
- frontend-lib-content-components
- frontend-lib-special-exams
- paragon
- studio-frontend
runs-on: ubuntu-latest
continue-on-error: true
needs: [setup-branch, python-translations]
steps:
# Clones the openedx-translations repo
- name: clone openedx/openedx-translations
uses: actions/checkout@v3
with:
ref: ${{ needs.setup-branch.outputs.branch }}

# Clones the repository
- name: clone openedx/${{ matrix.repo }}
uses: actions/checkout@v3
with:
repository: openedx/${{ matrix.repo }}
path: translations/${{ matrix.repo }}
# js-translations:
# strategy:
# # using max-parallel to avoid git push/pull issues when running in parallel
# max-parallel: 1
# matrix:
# # repos missing extract_translations target in makefile:
# # * frontend-app-admin-portal
# # * frontend-app-publisher
# # * frontend-platform
# # * frontend-enterprise?
# # * frontend-app-learner-portal-enterprise
# # * frontend-build?
# # * frontend-app-learner-portal-programs
# # * frontend-component-cookie-policy-banner
# # * frontend-app-programs-dashboard
# # studio-frontend has a different file structure
# # repos with errors running extract_translations
# # * frontend-template-application
# repo:
# - studio-frontend
## - frontend-app-account
## - frontend-app-authn
## - frontend-app-communications
## - frontend-app-course-authoring
## - frontend-app-discussions
## - frontend-app-ecommerce
## - frontend-app-enterprise-public-catalog
## - frontend-app-gradebook
## - frontend-app-learner-dashboard
## - frontend-app-learner-record
## - frontend-app-learning
## - frontend-app-library-authoring
## - frontend-app-ora-grading
## - frontend-app-payment
## - frontend-app-profile
## - frontend-app-program-console
## - frontend-app-support-tools
## - frontend-component-footer
## - frontend-component-header
## - paragon
## - studio-frontend
# runs-on: ubuntu-latest
# continue-on-error: true
# needs: [setup-branch, python-translations]
# steps:
# # Clones the openedx-translations repo
# - name: clone openedx/openedx-translations
# uses: actions/checkout@v3
# with:
# ref: ${{ needs.setup-branch.outputs.branch }}
#
# # Clones the repository
# - name: clone openedx/${{ matrix.repo }}
# uses: actions/checkout@v3
# with:
# repository: openedx/${{ matrix.repo }}
# path: translations/${{ matrix.repo }}
#
# # Sets up node/npm
# - name: setup node
# uses: actions/setup-node@v3
# with:
# node-version: 16
#
# # Extracts the translation source files
# - name: extract translation source files
# run: |
# cd translations/${{ matrix.repo }}
# make extract_translations
# # git adds only the translation source files, found in src/i18n/transifex_input.json
# - name: git add the translation source files
# id: add-sources
# run: |
# # set identity
# git config --global user.email "translations-bot@openedx.org"
# git config --global user.name "edx-transifex-bot"
# # Change directory to translations/${{ matrix.repo }}
# cd translations/${{ matrix.repo }}
# # remove translations/${{ matrix.repo }}/.git so we don't commit a submodule
# rm -rf .git
# # find transifex_input.json
# TRANSIFEX_JSON_PATH=$(find . -name 'transifex_input.json')
# # stage the transifex_input.json file generated by make
# git add $TRANSIFEX_JSON_PATH -f -v
# # Check the git status of the translation source files
# echo "GIT_STATUS=$(git status $TRANSIFEX_JSON_PATH -s | wc -l)" >> $GITHUB_ENV
# # Attempts to commit the translation source files if there is a difference
# - name: git commit the translation source files
# if: "${{ env.GIT_STATUS > 0 }}"
# run: |
# # commit the changes
# git commit -m "chore: add extracted translation source files from ${{ matrix.repo }}"
# # push changes to branch
# git push

# Sets up node/npm
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 16

# Extracts the translation source files
- name: extract translation source files
run: |
cd translations/${{ matrix.repo }}
make extract_translations
# git adds only the translation source files, found in src/i18n/transifex_input.json
- name: git add the translation source files
id: add-sources
run: |
# set identity
git config --global user.email "translations-bot@openedx.org"
git config --global user.name "edx-transifex-bot"
# Change directory to translations/${{ matrix.repo }}
cd translations/${{ matrix.repo }}
# remove translations/${{ matrix.repo }}/.git so we don't commit a submodule
rm -rf .git
# find transifex_input.json
TRANSIFEX_JSON_PATH=$(find . -name 'transifex_input.json')
# stage the transifex_input.json file generated by make
git add $TRANSIFEX_JSON_PATH -f -v
# Check the git status of the translation source files
echo "GIT_STATUS=$(git status $TRANSIFEX_JSON_PATH -s | wc -l)" >> $GITHUB_ENV
# Attempts to commit the translation source files if there is a difference
- name: git commit the translation source files
if: "${{ env.GIT_STATUS > 0 }}"
run: |
# commit the changes
git commit -m "chore: add extracted translation source files from ${{ matrix.repo }}"
# push changes to branch
git push

merge-translations:
runs-on: ubuntu-latest
needs: [setup-branch, python-translations, js-translations]
# needs: [setup-branch, python-translations, js-translations]
needs: [setup-branch, python-translations]

steps:
# Clones the openedx-translations repo on the automated/extract-translation-source-files-# branch
- name: clone openedx/openedx-translations
- name: clone Zeit-Labs/openedx-translations
uses: actions/checkout@v3
with:
ref: ${{ needs.setup-branch.outputs.branch }}
Expand All @@ -222,25 +234,26 @@ jobs:
- name: create pull request
id: createPR
env:
# This token requires Write access to the openedx-translations repo
GITHUB_TOKEN: ${{ secrets.EDX_TRANSIFEX_BOT_GITHUB_TOKEN }}
# # This token requires Write access to the openedx-translations repo
# GITHUB_TOKEN: ${{ secrets.EDX_TRANSIFEX_BOT_GITHUB_TOKEN }}
GH_TOKEN: ${{ github.token }}
run: |
echo "COMMIT_COUNT=$(git rev-list HEAD ^origin/main | wc -l)" >> $GITHUB_ENV
echo "PR_URL=$(gh pr create --title 'chore: add updated translation source files' --body 'This PR is auto-generated by [extract-translation-source-files](https://github.com/openedx/openedx-translations/blob/master/.github/workflows/extract-translation-source-files.yml).')" >> $GITHUB_ENV
echo "PR_URL=$(gh pr create -d --title 'chore: add updated translation source files' --body 'This PR is auto-generated by [extract-translation-source-files](https://github.com/openedx/openedx-translations/blob/master/.github/workflows/extract-translation-source-files.yml).')" >> $GITHUB_ENV

# Merges the pull request
- name: merge pull request
id: mergePR
env:
# This token requires Write access to the openedx-translations repo
GITHUB_TOKEN: ${{ secrets.EDX_TRANSIFEX_BOT_GITHUB_TOKEN }}
if: "${{ env.COMMIT_COUNT > 0 }}"
run: gh pr merge ${{ env.PR_URL }} --merge --auto

# Notify that branch did not merge because there were no new commits in the branch
# and delete the branch now that it is unnecessary
- name: notify of empty branch and delete branch
if: (steps.mergePR.outcome == 'skipped')
run: |
echo "The branch was not merged because the branch had 0 commits."
git push origin -d ${{ needs.setup-branch.outputs.branch }}
# # Merges the pull request
# - name: merge pull request
# id: mergePR
# env:
# # This token requires Write access to the openedx-translations repo
# GITHUB_TOKEN: ${{ secrets.EDX_TRANSIFEX_BOT_GITHUB_TOKEN }}
# if: "${{ env.COMMIT_COUNT > 0 }}"
# run: gh pr merge ${{ env.PR_URL }} --merge --auto
#
# # Notify that branch did not merge because there were no new commits in the branch
# # and delete the branch now that it is unnecessary
# - name: notify of empty branch and delete branch
# if: (steps.mergePR.outcome == 'skipped')
# run: |
# echo "The branch was not merged because the branch had 0 commits."
# git push origin -d ${{ needs.setup-branch.outputs.branch }}
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ upgrade: piptools ## update the requirements/*.txt files with the latest packag
pip install -qr requirements/pip.txt
pip install -qr requirements/pip_tools.txt
pip-compile --rebuild --upgrade -o requirements/translations.txt requirements/translations.in

Loading