From 4360021b3eced84e0b225806a61b4a538f9ce141 Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Thu, 10 Aug 2023 13:06:28 +0300 Subject: [PATCH] feat: extract from edx-platform This contribution is part of the [FC-0012 project](https://openedx.atlassian.net/l/cp/XGS0iCcQ) which is sparked by the [Translation Infrastructure update OEP-58](https://open-edx-proposals.readthedocs.io/en/latest/architectural-decisions/oep-0058-arch-translations-management.html#specification). --- .../extract-translation-source-files.yml | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/.github/workflows/extract-translation-source-files.yml b/.github/workflows/extract-translation-source-files.yml index 1b55b3dba23..28955701cd0 100644 --- a/.github/workflows/extract-translation-source-files.yml +++ b/.github/workflows/extract-translation-source-files.yml @@ -79,6 +79,7 @@ jobs: python_module_name: sql_grader - repo_name: xblock-submit-and-compare python_module_name: submit_and_compare + - repo_name: edx-platform runs-on: ubuntu-latest continue-on-error: true @@ -102,15 +103,40 @@ jobs: repository: openedx/${{ matrix.repo.repo_name }} path: translations/${{ matrix.repo.repo_name }} - # Sets up Python + + - name: prepare the environment with edx-platform specific changes + if: matrix.repo.repo_name == 'edx-platform' + run: | + # This is needed for edx-platform base.txt packages + sudo apt install -y libxml2-dev libxmlsec1-dev libxslt1-dev + + # Remove unwanted `en` django/djangojs po files + rm -rf translations/${{ matrix.repo.repo_name }}/conf/locale/en + mkdir -p translations/${{ matrix.repo.repo_name }}/conf/locale/en/LC_MESSAGES + + # Setup Python - name: setup python uses: actions/setup-python@v4 + id: setup_python with: python-version: '3.8' + cache: pip + # Using wild-card for `edx-platf*rm` -> `edx-platform` which separates its dependencies from other repos + cache-dependency-path: | + requirements/translations.txt + translations/edx-platf*rm/requirements/edx/base.txt # Installs Python requirements from translations.txt - name: install requirements - run: pip install -r requirements/translations.txt + run: | + # Install requirements for all packages + pip install -r requirements/translations.txt + + EDX_BASE_REQS=translations/edx-platform/requirements/edx/base.txt + if test -f $EDX_BASE_REQS; then + # Install edx-platform specific apps (e.g. wiki) which is required to extrat translations from + pip install -r $EDX_BASE_REQS + fi # Extracts the translation source files - name: extract translation source files @@ -135,7 +161,8 @@ jobs: cd translations/${{ matrix.repo.repo_name }} # finds the directory containing the english locale usually located in # */*/conf/locale/en - EN_DIR=$(find . -type d -regex ".+conf\/locale\/en$") + EN_DIR=$(find . -type d -regex ".+conf\/locale\/en$" | head -n 1) + echo "EN_DIR=$EN_DIR" >> $GITHUB_ENV # If the directory is not found, exit with an error. This can happen if we add a repository that doesn't # comply with OEP-58, or it still doesn't have any translations yet if [ -z "$EN_DIR" ]; then @@ -145,8 +172,14 @@ jobs: fi # remove translations/${{ matrix.repo.repo_name }}/.git so we don't commit a submodule rm -rf .git + + # All repositories except for edx-platform follows the standard Django i18n pattern + - name: add repo translation source files openedx-translations + if: matrix.repo.repo_name != 'edx-platform' + run: | # finds the django.po and djangojs.po files generated by make # extract_translations into EN_DIR and adds them + cd translations/${{ matrix.repo.repo_name }} DJANGO_PATH=$(find $EN_DIR -name 'django.po') DJANGOJS_PATH=$(find $EN_DIR -name 'djangojs.po') # use (-f) to force add the files even if they are ignored in the source repo @@ -154,6 +187,16 @@ jobs: # Check the git statuses of the translation source files echo "GIT_STATUS=$(git status $DJANGO_PATH $DJANGOJS_PATH -s | wc -l)" >> $GITHUB_ENV + # edx-platform has multiple i18n files + - name: add edx-platform translation source files openedx-translations + if: matrix.repo.repo_name == 'edx-platform' + run: | + cd translations/${{ matrix.repo.repo_name }} + git add -f -v conf/locale/en/LC_MESSAGES/*.po + # Check the git statuses of the translation source files + echo "GIT_STATUS=$(git status conf/locale/en -s | wc -l)" >> $GITHUB_ENV + + # This applies for all repositories that are _installable_ inside edx-platform - name: create plugin/xblock link if: ${{ matrix.repo.python_module_name }} run: |