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

Conversation

bmtcril
Copy link
Contributor

@bmtcril bmtcril commented Oct 12, 2023

For non-Django, non-JS projects we should be able to extract translations just using make commands and a small set of assumptions about where the source English file can be found. This adds that functionality and an integration with tutor-contrib-aspects which needs it.

Depends on openedx/tutor-contrib-aspects#462 being merged

For non-Django, non-JS projects we should be able
to extract translations just using make commands
and a small set of assumptions about where the
source English file can be found. This adds that
functionality and an integration with
tutor-contrib-aspects which needs it.
@bmtcril
Copy link
Contributor Author

bmtcril commented Oct 12, 2023

@brian-smith-tcril I think this implements what we'd talked about in Slack. The referenced PR above may or may not work for using Atlas to pull the translated files from this repo, but we can't test it until there are some translations in place.

I'm hoping that PR and this one get us at least to the place where folks can start translating and we can debug the pull part of the pipeline from there. Leaving this in draft until the other PR lands, though.

Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

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

Overall this looks great! I left a comment with an idea, and I'm looking forward to hearing your thoughts!

.github/workflows/extract-translation-source-files.yml Outdated Show resolved Hide resolved
bmtcril added a commit to openedx/tutor-contrib-aspects that referenced this pull request Oct 13, 2023
Per feedback in openedx/openedx-translations#1834 this is really just a temp file, so we should treat it as one. Also adding a README to the locale dir to deter people from editing those files.
This relies on the extract_translations make target
in each "generic" repo to create a
transifex_input.yaml in the root of the site,
which greatly simplifies the process.
@bmtcril bmtcril marked this pull request as ready for review October 13, 2023 15:10
transifex.yml Outdated Show resolved Hide resolved
Co-authored-by: Brian Smith <[email protected]>
Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

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

LGTM! :shipit:

Copy link
Member

@OmarIthawi OmarIthawi left a comment

Choose a reason for hiding this comment

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

Thanks @bmtcril!

I see the find as a hack, but an acceptable trade-off until we standardize them.

However, for other repositories esp. the generic steps I recommend setting an explicit path. We don't expect to have too many of those repositories anyway to justify a find imo.

Ideally this step can be used for the Android app, but that's a topic for another day.

Please let me know what do you think.

Comment on lines 316 to 321
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

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

@bmtcril
Copy link
Contributor Author

bmtcril commented Oct 16, 2023

@OmarIthawi I took a stab at your suggestions. I couldn't find a use of matrix like that in some looking around, so I'm not sure how it will work. Let me know what you think.

Copy link
Member

@OmarIthawi OmarIthawi left a comment

Choose a reason for hiding this comment

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

Thanks @bmtcril! Looks great.

Usually we require a testing on your fork, would you mind following this document to ensure the workflow works?

Comment on lines +265 to +267
repository_config:
- repo: tutor-contrib-aspects
transifex_file_path: transifex_input.yaml
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.

@bmtcril bmtcril marked this pull request as draft October 17, 2023 13:25
@bmtcril
Copy link
Contributor Author

bmtcril commented Oct 17, 2023

Making this a draft while I test in my fork, hopefully will stop spamming people with errors

@bmtcril bmtcril force-pushed the bmtcril/add_generic_extract branch from 44a2475 to 94bb36a Compare October 17, 2023 13:42
@bmtcril bmtcril marked this pull request as ready for review October 17, 2023 13:43
@bmtcril
Copy link
Contributor Author

bmtcril commented Oct 17, 2023

@OmarIthawi the test ran successfully on my fork and created this commit: bmtcril@2ada561

@OmarIthawi
Copy link
Member

Awesome @bmtcril!! I'm merging this. Thanks for your contribution and verifying that both this PR and documentation works!!

@OmarIthawi OmarIthawi merged commit 1945bd4 into openedx:main Oct 17, 2023
8 checks passed
@bmtcril bmtcril deleted the bmtcril/add_generic_extract branch April 11, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants