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: atlas pull for XBlock translations | FC-0012 #33698

Merged
merged 2 commits into from
Jan 12, 2024

Conversation

OmarIthawi
Copy link
Member

@OmarIthawi OmarIthawi commented Nov 10, 2023

Implements the following proposal:

Known limitations

  • Test i18n translations:
    • JavaScript
    • Python
  • This won't pull other plugin translations such as edx-val and any non-XBlock library. A follow up pull request will be created.
  • Address translation.to_locale(lang_code) vs translation.to_locale(translation.get_language())
  • Fix get_statici18n_js_url
  • Refactor settings location and shared variables
  • Consider a dedicated plugin_translations edX Platform module independent of XBlock module
  • Fix failed tests
  • Update the method and directory names to match the python implementation in the 0019-oep-58-atlas-translations-design.rst document
  • Upgrade XBlock to 1.9.0:
  • Ensure non--verbose silent the output is respected in pull_xblock_translations, otherwise remove the command

Testing instructions

Install the Drag and Drop v2 fork which supports OEP-58 translations:

devstack $ make cms-shell
edx-platform # pip uninstall xblock-drag-and-drop-v2
edx-platform # pip install -e https:/Zeit-Labs/xblock-drag-and-drop-v2/archive/atlas-translations.zip
edx-platform # make OPENEDX_ATLAS_PULL=yes pull_xblock_translations
devstack $ make cms-restart

Then add a Drag and Drop XBlock instance and it should use the translations from the atlas pull results instead of the bundled ones.

Of course, it'll be difficult to distinguish which is which, therefore I've hacked the process as described in the Testing results.

Testing results

I've manually replaced the atlas pull French translations with Chinese so I ensure that I'm not just seeing stale translations.

This is a temp. hack during testing and it looks like the Drag and Drop v2 translation is being pulled correctly via atlas.

These are the lines that I've added after the atlas pull command:

def atlas_pull_xblock_by_module_names():
    ...
    # This hack purpose is to make it obvious that the translations are working by showing Chinese instead of Arabic.
    for dummy_lang in ['ar', 'fr']:
        subprocess.run(
            args=f'rm -rf {dummy_lang} && cp -r zh_CN {dummy_lang}',
            shell=True,
            cwd=f'{XBLOCK_TRANSLATIONS_ROOT}/drag_and_drop_v2/conf/locale',
            check=True,
        )
Screenshots

Python code translations
Screenshot from 2023-11-12 22-26-02

JavaScript code translations
Screenshot from 2023-11-12 22-26-20

Refs

This pull request is part of the FC-0012 project which implements the Translation Infrastructure update OEP-58.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Nov 10, 2023
@openedx-webhooks
Copy link

openedx-webhooks commented Nov 10, 2023

Thanks for the pull request, @OmarIthawi! 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:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

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.

@OmarIthawi OmarIthawi changed the title feat: atlas pull for XBlock translations feat: atlas pull for XBlock translations | FC-0012 Nov 10, 2023
@OmarIthawi OmarIthawi force-pushed the i18n-service-oep58 branch 2 times, most recently from 35ef496 to 238a29f Compare November 12, 2023 11:45
common/djangoapps/xblock_django/api.py Outdated Show resolved Hide resolved
common/djangoapps/xblock_django/plugin_translations.py Outdated Show resolved Hide resolved
common/djangoapps/xblock_django/plugin_translations.py Outdated Show resolved Hide resolved


def get_javascript_i18n_file_path(xblock_module, locale):
return settings.STATICI18N_ROOT / get_javascript_i18n_file(xblock_module, locale)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here you're returning a path type but above you're returning a string, is there a reason for that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Generally, Path and str are interchangeable and get_javascript_i18n_file_name is used for URLs as well as file system paths. Therefore, it makes sense to use str imo.

common/djangoapps/xblock_django/plugin_translations.py Outdated Show resolved Hide resolved
xmodule/modulestore/django.py Outdated Show resolved Hide resolved
xmodule/modulestore/django.py Outdated Show resolved Hide resolved
xmodule/modulestore/django.py Outdated Show resolved Hide resolved
xmodule/waffle.py Outdated Show resolved Hide resolved
@OmarIthawi OmarIthawi force-pushed the i18n-service-oep58 branch 3 times, most recently from 8f8b91c to 00f2eb6 Compare November 16, 2023 06:28
.gitignore Outdated Show resolved Hide resolved
@OmarIthawi
Copy link
Member Author

OmarIthawi commented Nov 17, 2023

@feanil @kdmccormick Thanks a lot for the code review yesterday!

I've addressed most of the review comments already and added the rest as TODO check list items in the GitHub pull request description. Feel free to take a look now or later after tests are fixed.

I'll fix tests and tag you for a review before I start adding new test cases.

cc: @brian-smith-tcril

Copy link
Contributor

@feanil feanil left a comment

Choose a reason for hiding this comment

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

Changes look good to me, I like the more general management command names also so it will be good to update the docs to match as you are already planning to do.

@OmarIthawi
Copy link
Member Author

Thanks @feanil for the review. I'll finish the remainder TODOs, add tests and let you know when I'm done for a final review.

@OmarIthawi
Copy link
Member Author

@feanil this is ready again for review. I've added tests and refactored the work into reusable modules for future work (within FC-0012).

@feanil
Copy link
Contributor

feanil commented Dec 21, 2023

Hey Omar, sounds good. FYI, I'm going on vacation for the next week so I probably won't get to this till the new year but I'll review it as soon as I can after I'm back. Looks like there are still some test failures to deal with. Let me know if you want me to wait for fixes or if I should start review as soon as I can.

Copy link
Contributor

@feanil feanil left a comment

Choose a reason for hiding this comment

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

Generally looks like it's ready to go, I had one question about an empty test file.

Makefile Outdated
@@ -55,8 +56,19 @@ endif
push_translations: ## push source strings to Transifex for translation
i18n_tool transifex push

pull_translations: ## pull translations from Transifex
pull_xblock_translations:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pull_xblock_translations:
pull_xblock_translations: ## pull xblock translations via atlas

This comment becomes the help text for make help so it's useful to have something.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this file supposed to be empty?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, i forgot to add test for this one

@OmarIthawi OmarIthawi force-pushed the i18n-service-oep58 branch 2 times, most recently from e27e4a3 to b18e222 Compare January 3, 2024 16:44
@feanil
Copy link
Contributor

feanil commented Jan 3, 2024

@OmarIthawi it looks like this is good to go, is there anything else we need to do before we merge this?

@OmarIthawi OmarIthawi force-pushed the i18n-service-oep58 branch 2 times, most recently from e18e3bf to 5c7f47b Compare January 3, 2024 19:15
@OmarIthawi
Copy link
Member Author

@feanil I think it's ready, I've pushed it with few more tests in test_i18n_api.py.

@OmarIthawi
Copy link
Member Author

@feanil @brian-smith-tcril A gentle reminder that this pull request is ready to be merged.

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.

Left a couple small docs suggestions but overall this LGTM!

docs/decisions/0019-oep-58-atlas-translations-design.rst Outdated Show resolved Hide resolved
docs/decisions/0019-oep-58-atlas-translations-design.rst Outdated Show resolved Hide resolved
docs/decisions/0019-oep-58-atlas-translations-design.rst Outdated Show resolved Hide resolved
@feanil
Copy link
Contributor

feanil commented Jan 10, 2024

@OmarIthawi if the suggestions look good to you, can you add them in? I can merge this PR tomorrow morning our time.

@feanil
Copy link
Contributor

feanil commented Jan 11, 2024

Looks like this needs a rebase and conflict resolution as well now that the other atlas PR landed.

find conf/locale -mindepth 1 -maxdepth 1 -type d -exec rm -r {} \;
atlas pull $(OPENEDX_ATLAS_ARGS) translations/edx-platform/conf/locale:conf/locale
atlas pull $(ATLAS_OPTIONS) translations/edx-platform/conf/locale:conf/locale
Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @feanil for the quick triage.

Conflicts has been resolved and I've tested it again and it seems to be playing well.

I've changed this line to match the Tutor option to have one less surprise for operators.

@feanil feanil merged commit e7fc0c6 into openedx:master Jan 12, 2024
64 checks passed
@openedx-webhooks
Copy link

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

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants