openedx / i18n-tools

Tools to help with internationalization and localization of Open edX projects
Apache License 2.0
26 stars 31 forks source link

feat: add new options merge-po-files and no-segment #134

Closed shadinaif closed 1 year ago

shadinaif commented 1 year ago

feat: add two new options, merge-po-files and no-segment

After we passed a lot of steps in FC-0012 project; we see a need to add the following options to extract command because it'll serve us in a shared logic between many other packages (especially XBlocks). So, instead of repeating the same logic in Makefiles; we just add the options. DRY, and more readable

Local Manual Testing

I used xblock-drag-and-drop-v2 locally to test extract command:

openedx-webhooks commented 1 year ago

Thanks for the pull request, @shadinaif! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02% :tada:

Comparison is base (27025f4) 99.75% compared to head (afabc56) 99.77%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #134 +/- ## ========================================== + Coverage 99.75% 99.77% +0.02% ========================================== Files 10 10 Lines 401 439 +38 Branches 27 31 +4 ========================================== + Hits 400 438 +38 Partials 1 1 ``` | [Files Changed](https://app.codecov.io/gh/openedx/i18n-tools/pull/134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openedx) | Coverage Δ | | |---|---|---| | [tests/test\_extract.py](https://app.codecov.io/gh/openedx/i18n-tools/pull/134?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openedx#diff-dGVzdHMvdGVzdF9leHRyYWN0LnB5) | `100.00% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

shadinaif commented 1 year ago

This one is ready @OmarIthawi @brian-smith-tcril , also tested on another package to ensure it's validity

OmarIthawi commented 1 year ago

Test 1: Drag and drop xblock ✅

CLI test log ``` $ cd xblock-drag-and-drop-v2 $ mkvirtualenv ... $ pip install -e git+https://github.com/Zeit-Labs/i18n-tools.git@shadinaif/new-options-for-extract#egg=edx-i18n-tools==1.1.0 $ make extract_translations cd drag_and_drop_v2 && i18n_tool extract --merge-js --no-partial INFO:i18n.execute:Executing in . ... INFO:i18n.execute:django-admin makemessages -l en -v0 --ignore="*/css/*" --ignore="public/js/translations/*" --ignore="public/js/vendor/*" -d django INFO:i18n.execute:Executing in . ... INFO:i18n.execute:django-admin makemessages -l en -v0 --ignore="*/css/*" --ignore="public/js/translations/*" --ignore="public/js/vendor/*" -d djangojs -e js,jsx INFO:i18n.extract:Cleaning djangojs-partial.po INFO:i18n.extract:Cleaning django-partial.po INFO:i18n.execute:Executing in /home/omar/work/openedx/xblock-drag-and-drop-v2/drag_and_drop_v2/conf/locale/en/LC_MESSAGES ... INFO:i18n.execute:msgcat django-partial.po djangojs-partial.po -o django-partial.po INFO:i18n.execute:Deleting file conf/locale/en/LC_MESSAGES/djangojs-partial.po INFO:i18n.execute:Deleting file conf/locale/en/LC_MESSAGES/django-saved.po INFO:i18n.execute:Deleting file conf/locale/en/LC_MESSAGES/djangojs-saved.po WARNING:i18n.execute:File does not exist: conf/locale/en/LC_MESSAGES/djangojs-saved.po mv drag_and_drop_v2/conf/locale/en/LC_MESSAGES/django.po drag_and_drop_v2/conf/locale/en/LC_MESSAGES/text.po $ git status On branch master Your branch is up to date with 'upstream/master'. Changes to be committed: (use "git restore --staged ..." to unstage) modified: Makefile deleted: drag_and_drop_v2/conf/locale/en/LC_MESSAGES/django.po typechange: drag_and_drop_v2/conf/locale/en/LC_MESSAGES/text.po ```

It works great, but leaves the following side-effects:

Admittedly, this behavior isn't going to break anything so it's perhaps clunky but okay to have since XBlocks needs to explicitly use the new flags and those XBlocks should avoid adding the mv rename command.

Test 2: LTI Consumer XBlock ✅

CLI commands and results ``` $ mkvirtualenv ... $ pip install -r requirements/test.txt $ pip install -e git+https://github.com/Zeit-Labs/i18n-tools.git@shadinaif/new-options-for-extract#egg=edx-i18n-tools==1.1.0 $ make extract_translations cd lti_consumer && i18n_tool extract --merge-js --no-partial INFO:i18n.execute:Executing in . ... INFO:i18n.execute:django-admin makemessages -l en -v0 --ignore="*/css/*" --ignore="*/sass/*" --ignore="public/js/translations/*" --ignore="translations/*" --ignore="locale/*" -d django INFO:i18n.execute:Executing in . ... INFO:i18n.execute:django-admin makemessages -l en -v0 --ignore="*/css/*" --ignore="*/sass/*" --ignore="public/js/translations/*" --ignore="translations/*" --ignore="locale/*" -d djangojs -e js,jsx INFO:i18n.extract:Cleaning django-partial.po INFO:i18n.extract:Cleaning djangojs-partial.po INFO:i18n.execute:Executing in /home/omar/work/openedx/xblock-lti-consumer/lti_consumer/locale/en/LC_MESSAGES ... INFO:i18n.execute:msgcat django-partial.po djangojs-partial.po -o django-partial.po INFO:i18n.execute:Deleting file locale/en/LC_MESSAGES/djangojs-partial.po INFO:i18n.execute:Deleting file locale/en/LC_MESSAGES/django-saved.po WARNING:i18n.execute:File does not exist: locale/en/LC_MESSAGES/django-saved.po INFO:i18n.execute:Deleting file locale/en/LC_MESSAGES/djangojs-saved.po WARNING:i18n.execute:File does not exist: locale/en/LC_MESSAGES/djangojs-saved.po mv lti_consumer/conf/locale/en/LC_MESSAGES/django.po lti_consumer/conf/locale/en/LC_MESSAGES/text.po $ git status On branch master Your branch is up to date with 'upstream/master'. Changes not staged for commit: (use "git add/rm ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: Makefile deleted: lti_consumer/conf/locale/en/LC_MESSAGES/django.po typechange: lti_consumer/conf/locale/en/LC_MESSAGES/text.po ```
shadinaif commented 1 year ago

Thank you @OmarIthawi , thank you @brian-smith-tcril . It is ready now

shadinaif commented 1 year ago

Please review again @OmarIthawi . I've tested again on both xblock-drag-and-drop and edx-platform. I believe we nailed it now :)

openedx-webhooks commented 1 year ago

@shadinaif 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.