-
Notifications
You must be signed in to change notification settings - Fork 51
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
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -254,6 +254,98 @@ jobs: | |
# push changes to branch | ||
git push | ||
|
||
# Non-Django, non-JS repositories with a generic extraction interface | ||
generic-translations: | ||
strategy: | ||
# using max-parallel to avoid git push/pull issues when running in parallel | ||
max-parallel: 1 | ||
matrix: | ||
repo: | ||
- tutor-contrib-aspects | ||
|
||
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 | ||
|
||
# Validate compilation of translation source files | ||
- name: validate compilation of translation source files | ||
run: | | ||
cd translations/${{ matrix.repo }} | ||
make compile_translations | ||
|
||
# git adds only the translation source files, found in conf/locale/en | ||
- 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 }} | ||
# finds the directory containing the english locale usually located | ||
# in */*/conf/locale/en | ||
# This is slightly different from the python-translations line above | ||
# in that it ignores top level dotfiles and searches further down the | ||
# directory tree, which may be needed in these use cases. | ||
EN_DIR=$(find ./* -type d -regex ".*conf\/locale\/en$") | ||
bmtcril marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# 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 | ||
# doesn't have any translations yet | ||
if [ -z "$EN_DIR" ]; then | ||
echo "Missing English locale directory for ${{ matrix.repo }}!" | ||
echo "exiting with error!" | ||
exit 1 | ||
fi | ||
# remove translations/${{ matrix.repo }}/.git so we don't commit a | ||
# submodule | ||
rm -rf .git | ||
|
||
# use (-f) to force add the files even if they are ignored in the | ||
# source repo | ||
git add -A $EN_DIR -f | ||
# Check the git statuses of the translation source files, this will | ||
# store the number of files staged for the next step | ||
echo "GIT_STATUS=$(git status $EN_DIR -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] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.