From a2eab636921fb3660739f5062af8e344b9400419 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 | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/.github/workflows/extract-translation-source-files.yml b/.github/workflows/extract-translation-source-files.yml index 1a51abb3575..fba014103a8 100644 --- a/.github/workflows/extract-translation-source-files.yml +++ b/.github/workflows/extract-translation-source-files.yml @@ -38,6 +38,7 @@ jobs: 'edx-ace', 'edx-bulk-grades', 'edx-ora2', + 'edx-platform', 'edx-proctoring', 'FeedbackXBlock', 'RecommenderXBlock', @@ -181,21 +182,51 @@ jobs: repository: openedx/${{ matrix.repo }} path: translations/${{ matrix.repo }} - # Sets up Python + - name: Avoid committing translations into the `openedx-translations` other than source + run: | + find translations/${{ matrix.repo }}/conf/locale -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} \; + mkdir -p translations/${{ matrix.repo }}/conf/locale/en/LC_MESSAGES + + - name: prepare the environment with edx-platform specific changes + if: matrix.repo == 'edx-platform' + run: | + # This is needed for edx-platform base.txt packages + sudo apt install -y libxml2-dev libxmlsec1-dev libxslt1-dev + + # There is a theme directory with it's own conf/locale directory, we need to remove that + rm -rf translations/${{ matrix.repo }}/themes/conf + + # 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 extract translations from + pip install -r $EDX_BASE_REQS + fi # Extracts the translation source files - name: extract translation source files run: | cd translations/${{ matrix.repo }} make extract_translations + env: + IS_OPENEDX_TRANSLATIONS_WORKFLOW: yes # Validate compilation of translation source files - name: validate compilation of translation source files @@ -214,7 +245,7 @@ jobs: cd translations/${{ matrix.repo }} # 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) # 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 @@ -224,8 +255,12 @@ jobs: fi # remove translations/${{ matrix.repo }}/.git so we don't commit a submodule rm -rf .git + + - name: add repo translation source files openedx-translations + run: | # finds the django.po and djangojs.po files generated by make # extract_translations into EN_DIR and adds them + cd translations/${{ matrix.repo }} DJANGO_PATH=$(find $EN_DIR -name 'django.po') DJANGOJS_PATH=$(find $EN_DIR -name 'djangojs.po') ############## Special support for XBlocks