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 gettext for JS translation #70

Merged

Conversation

shadinaif
Copy link
Contributor

@shadinaif shadinaif commented May 27, 2023

feat: Add gettext for JS translation

JS translations will not be fetched without directing gettext to the correct javascript file

References

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

Check the links above for full information about the overall project.

Internalization is being rearchitected in Open edX Python, XBlock, Micro-frontend, and other projects. There are a number of immediately visible changes:

  • Remove source and language translations from the repositories, hence no .json, .po or .mo files will be committed into the repos.
  • Add standardized make extract_translations in all repositories
  • Push user-facing messages strings into openedx/openedx-translations.
  • Integrate root repositories with openedx/openedx-atlas to pull translations on build/deploy time

Breaking Changes

One of the primary goals of the project is to avoid breaking changes. If you noticed any suspicious code, please raise your concern. But before that, please know the strategy we're following to avoid breaking changes

For XBlocks:

  • The standard translation path must be conf/locale. Therefore, we are creating a link from conf/locale to translations so Atlas can find the path without disrupting the current way of having translations locally within the XBlocks
  • openedx-translations will have a related PR that adds the XBlock to the pipeline. This will not affect the current way of managing/updating translations
  • At the end of the project, a clear change log will be added and all translations will be handled by Atlas. Thus, the local translation will be removed from the repo within the version bump
  • A notification for the community will be published to ensure that everyone knows why translations directories are removed from all repos

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

openedx-webhooks commented May 27, 2023

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:

  • 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
Copy link
Member

@shadinaif what's the status of this PR? Do we still need this fix after the recent work you've done?

@mphilbrick211
Copy link

Hi @shadinaif and @OmarIthawi - just checking to see if this can be closed?

@OmarIthawi
Copy link
Member

@shadinaif I think we should add the following note to the PR description:

This contribution is part of the FC-0012 project which is sparked by the Translation Infrastructure update OEP-58.

Is this a follow up to the PR below?

@OmarIthawi
Copy link
Member

Hi @shadinaif and @OmarIthawi - just checking to see if this can be closed?

It seems to be pending work that we forgot to follow up on.

@shadinaif shadinaif changed the title WIP - Fix JS translation feat: Add gettext for JS translation Sep 13, 2023
@@ -78,10 +78,10 @@ def get_version(file_path):
license='AGPL 3.0',
entry_points={
'xblock.v1': [
'recommender = recommender:RecommenderXBlock',
'recommender = recommender.recommender:RecommenderXBlock',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

because we're not importing RecommenderXBlock in __init__.py

@shadinaif shadinaif marked this pull request as ready for review September 13, 2023 06:35
@shadinaif
Copy link
Contributor Author

@OmarIthawi, @brian-smith-tcril please review. This one is ready

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.

sorry, this is an old review that I haven't posted it.

Makefile Outdated
@@ -31,3 +32,7 @@ extract_translations: ## extract strings to be translated, outputting .po files
fi
Copy link
Member

Choose a reason for hiding this comment

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

@shadinaif now the i18n-tools==1.2.0 package has been released. Would you mind using it here?

I suppose this XBlock won't use the --merge-po-files option, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it will use the option @OmarIthawi , but this goes into another PR

  • Upgrade requirements
  • Use new options --no-segment --merge-po-files
  • Remove django.po and the text.po symlink

@OmarIthawi OmarIthawi self-requested a review September 21, 2023 09:55
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.

A minor change before this is ready to go.

manage.py Outdated Show resolved Hide resolved
recommender/conf/locale/settings.py Outdated Show resolved Hide resolved
@OmarIthawi OmarIthawi self-requested a review September 21, 2023 14:37
@mphilbrick211 mphilbrick211 added waiting for eng review PR is ready for review. Review and merge it, or suggest changes. and removed waiting for eng review PR is ready for review. Review and merge it, or suggest changes. labels Oct 3, 2023
@shadinaif shadinaif force-pushed the shadinaif/FC-0012-OEP-58.05 branch 3 times, most recently from 43374da to 95fdb79 Compare October 10, 2023 07:04
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 @shadinaif! Please test it on the openedx-translations repo and it's should be ready to get merged.

@shadinaif
Copy link
Contributor Author

all good @OmarIthawi , please take a final look

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 @shadinaif!! Looks great!

@brian-smith-tcril
Copy link
Contributor

@OmarIthawi I see that you recommended dev_settings.py as a filename. I don't see that filename used in other XBlocks throughout the org. I do see test_settings.py used quite often, would that name be inappropriate here?

@brian-smith-tcril
Copy link
Contributor

I see that dev_settings.py is being added here too openedx/edx-cookiecutters#382. Is the expectation that this file would contain more than just locale settings? If not, would locale_settings.py work? It's just not clear to me what dev_settings entails.

@OmarIthawi
Copy link
Member

@OmarIthawi I see that you recommended dev_settings.py as a filename. I don't see that filename used in other XBlocks throughout the org. I do see test_settings.py used quite often, would that name be inappropriate here?

Good question @brian-smith-tcril . Here's why I recommended dev_settings.py.

  • test_settings.py: implies testing and unit tests, but we need it for locale and development.
  • locale_settings.py: is accurate in this context, but the file might be repurposed in the future, so the name wouldn't be helpful.
  • dev_settings.py: is indeed a new name, which servers a shared for testing, locale and development.

Please let me know what's your thoughts. I'm okay with reverting back to locale or even test if you think it's more appropriate.

I'll copy this comment into openedx/edx-cookiecutters#382.

@brian-smith-tcril
Copy link
Contributor

For consistency with the naming decided on in openedx/edx-cookiecutters#382 (comment), we should rename dev_settings.py to translation_settings.py

JS translations will not be shown fetched without directing (gettext) to the
correct javascript file

Refs: FC-0012 OEP-58
@shadinaif
Copy link
Contributor Author

For consistency with the naming decided on in openedx/edx-cookiecutters#382 (comment), we should rename dev_settings.py to translation_settings.py

Thank you @brian-smith-tcril , Done

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.

This looks great!

Comment on lines -29 to -32
# edx-sphinx-theme is not compatible with latest Sphinx==6.0.0 version
# Pinning Sphinx version unless the compatibility issue gets resolved
# For details, see issue https://github.com/openedx/edx-sphinx-theme/issues/197
sphinx<6.0.0
Copy link
Contributor

@brian-smith-tcril brian-smith-tcril Oct 18, 2023

Choose a reason for hiding this comment

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

This stood out to me when I was looking through this PR so I'm leaving a comment to provide context

Removing this is definitely the right call.

@brian-smith-tcril brian-smith-tcril merged commit d32e7e4 into openedx:master Oct 18, 2023
3 checks passed
@openedx-webhooks
Copy link

@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.

@shadinaif shadinaif deleted the shadinaif/FC-0012-OEP-58.05 branch October 19, 2023 11:56
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