diff --git a/.github/workflows/extract-translation-source-files.yml b/.github/workflows/extract-translation-source-files.yml index 0149c86cbc7..e31b1b91929 100644 --- a/.github/workflows/extract-translation-source-files.yml +++ b/.github/workflows/extract-translation-source-files.yml @@ -39,6 +39,7 @@ jobs: 'edx-ace', 'edx-bulk-grades', 'edx-ora2', + 'edx-platform', 'edx-proctoring', 'FeedbackXBlock', 'RecommenderXBlock', @@ -182,21 +183,47 @@ jobs: repository: openedx/${{ matrix.repo }} path: translations/${{ matrix.repo }} - # Sets up Python + - 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 + # The `edx-platf*rm` wildcard will be expanded to `edx-platform` if its requirement file exists, + # otherwise it will be omitted + 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 @@ -204,8 +231,8 @@ jobs: cd translations/${{ matrix.repo }} django-admin compilemessages --locale en - # git adds only the translation source files, found in conf/locale/en - - name: git add the translation source files + # Preparations so git adds only the translation source files, found in conf/locale/en + - name: find the location of the translation source files id: add-sources run: | # set identity @@ -217,17 +244,26 @@ jobs: # */*/conf/locale/en # but also exclude any hidden directories that might exist for some reason EN_DIR=$(find . -type d -not -path '*/.*' -regex ".+conf\/locale\/en$") - # 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 - echo "Missing English locale directory for ${{ matrix.repo }}!" - echo "exiting with error!" + en_dir_count=$(echo "$EN_DIR" | wc -l) + # If the repo complies with OEP-58, then we'll find only one directory that matches the above criteria + # Otherwise, we'll consider it an error + if [ $en_dir_count -gt 1 ]; then + echo "Error: More than one English locale directory found for ${{ matrix.repo }}!" + exit 1 + elif [ $en_dir_count -eq 0 ]; then + echo "Error: Missing English locale directory for ${{ matrix.repo }}!" exit 1 fi + # Save EN_DIR value to be used in next steps + echo "EN_DIR=$EN_DIR" >> $GITHUB_ENV # 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