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

feat: Add a new generic translation extraction type #1834

Merged
merged 4 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 76 additions & 1 deletion .github/workflows/extract-translation-source-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,84 @@ jobs:
# push changes to branch
git push

# Non-Django, non-JS repositories with a generic extraction interface. This
# assumes that a `extract_translations` make target exists and will create
# a transifex_input.yaml file in the root of the site.
generic-translations:
strategy:
# using max-parallel to avoid git push/pull issues when running in parallel
max-parallel: 1
matrix:
repository_config:
- repo: tutor-contrib-aspects
transifex_file_path: transifex_input.yaml
Comment on lines +265 to +267
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good.

I'm not sure if it's widely documented, but that's a proper GitHub matrix config to set the item as an object instead of a string.


runs-on: ubuntu-latest
continue-on-error: true
needs: [setup-branch]

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.repository_config.repo }}
uses: actions/checkout@v3
with:
repository: openedx/${{ matrix.repository_config.repo }}
path: translations/${{ matrix.repository_config.repo }}

# Sets up Python
- name: setup python
uses: actions/setup-python@v4
with:
python-version: '3.8'

# Installs Python requirements from translations.txt
- name: install requirements
run: pip install -r requirements/translations.txt

# Extracts the translation source files
- name: extract translation source files
run: |
cd translations/${{ matrix.repository_config.repo }}
make extract_translations

# git adds only the translation source file transifex_input.yaml from
# the repo root.
- name: git add the translation source files
id: add-sources
run: |
# set identity
git config --global user.email "[email protected]"
git config --global user.name "edx-transifex-bot"
# Change directory to translations/${{ matrix.repository_config.repo }}
cd translations/${{ matrix.repository_config.repo }}

# remove translations/${{ matrix.repository_config.repo }}/.git so we don't commit a submodule
rm -rf .git

# stage the transifex_input.yaml file generated by make, force it in
# case the file is in .gitignore (it should be)
git add ${{ matrix.repository_config.transifex_file_path }} -f -v
# Check the git status of the translation source files
echo "GIT_STATUS=$(git status ${{ matrix.repository_config.transifex_file_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.repository_config.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, generic-translations]

steps:
# Clones the openedx-translations repo on the automated/extract-translation-source-files-# branch
Expand Down
9 changes: 8 additions & 1 deletion transifex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ git:
source_language: en
source_file_dir: translations/FeedbackXBlock/feedback/conf/locale/en/
translation_files_expression: 'translations/FeedbackXBlock/feedback/conf/locale/<lang>/'

# frontend-app-account
- filter_type: file
file_format: KEYVALUEJSON
Expand Down Expand Up @@ -250,6 +250,13 @@ git:
source_file: translations/studio-frontend/src/i18n/transifex_input.json
translation_files_expression: 'translations/studio-frontend/src/i18n/messages/<lang>.json'

# tutor-contrib-aspects
- filter_type: file
file_format: YAML_GENERIC
source_language: en
source_file: translations/tutor-contrib-aspects/transifex_input.yaml
translation_files_expression: 'translations/tutor-contrib-aspects/tutoraspects/templates/aspects/apps/superset/conf/locale/<lang>/locale.yaml'

# xblock-drag-and-drop-v2
- filter_type: dir
file_format: PO
Expand Down