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 3 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
75 changes: 75 additions & 0 deletions .github/workflows/extract-translation-source-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,81 @@ 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:
repo:
- tutor-contrib-aspects
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- tutor-contrib-aspects
- repo: tutor-contrib-aspects
transifex_file_paths: some-path-to/transifex_input.yaml


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

# remove translations/${{ matrix.repo }}/.git so we don't commit a submodule
rm -rf .git
# find transifex_input.yaml
TRANSIFEX_YAML_PATH=$(find . -name 'transifex_input.yaml')
# stage the transifex_input.yaml file generated by make, force it in
# case the file is in .gitignore (it should be)
git add $TRANSIFEX_YAML_PATH -f -v
# Check the git status of the translation source files
echo "GIT_STATUS=$(git status $TRANSIFEX_YAML_PATH -s | wc -l)" >> $GITHUB_ENV
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
TRANSIFEX_YAML_PATH=$(find . -name 'transifex_input.yaml')
# stage the transifex_input.yaml file generated by make, force it in
# case the file is in .gitignore (it should be)
git add $TRANSIFEX_YAML_PATH -f -v
# Check the git status of the translation source files
echo "GIT_STATUS=$(git status $TRANSIFEX_YAML_PATH -s | wc -l)" >> $GITHUB_ENV
# stage the transifex_input.yaml file generated by make, force it in
# case the file is in .gitignore (it should be)
git add ${{ matrix.repo.transifex_file_paths }} -f -v
# Check the git status of the translation source files
echo "GIT_STATUS=$(git status ${{ matrix.repo.transifex_file_paths }} -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]
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