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: standardize make extract_translations #1751

Merged

Conversation

shadinaif
Copy link
Contributor

@shadinaif shadinaif commented May 9, 2023

feat: standardize make extract_translations

This PR prepares the repository to comply with openedx-translations by doing the following:

  • Move all local translations to conf/locale and convert translations into a symbolic link to conf/locale. The reason behind that is to comply with openedx-translations mechanism that requires translation files to be in conf/locale directory. This fix will avoid the need to modify find commands here
  • Add the translation command make extract_translations to build a file named django.po instead of text.po. And create a symbolic link from text.po to django.po. This is because openedx-translations requires django.po as the name of the file. And it must be a valid file (not a link) because it uses git add here
  • Tested on devstack palm to ensure that everything renders fine
  • Tested on devstack palm to ensure that local translation still works

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 9, 2023
@openedx-webhooks
Copy link

openedx-webhooks commented May 9, 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.

@shadinaif
Copy link
Contributor Author

Hi @iloveagent57 , I'm starting a PR for FC-0012 Project. Can you please explain why there are two translation directories? one for consent and integrate apps, and another for enterprise app. Shouldn't we combine them all in a single translation directory?

cc: @OmarIthawi, @brian-smith-tcril

@mphilbrick211 mphilbrick211 added needs test run Author's first PR to this repository, awaiting test authorization from Axim and removed needs test run Author's first PR to this repository, awaiting test authorization from Axim labels May 10, 2023
@iloveagent57
Copy link
Contributor

@shadinaif sorry for the delay in responding, I'll try to find someone with historical context on this. I don't personally know the answer.

@iloveagent57
Copy link
Contributor

@saleem-latif had some context here that he shared with me:
PR: #1037

I think the directory conf/locale was created alongside the edx-enterprise app. Initially, it only had markings for strings in the en directory, no translations were added. With ENT-3529 we wanted to add translations for Spanish (specifically for data sharing page. More information in the comments of ENT-3529 on this.)
The reason I added a new directory at this point is because Django provided following 3 ways to enable translations

  1. The directories listed in LOCALE_PATHS have the highest precedence, with the ones appearing first having higher precedence than the ones appearing later.
  2. Then, it looks for and uses if it exists a locale directory in each of the installed apps listed in INSTALLED_APPS. The ones appearing first have higher precedence than the ones appearing later.
  3. Finally, the Django-provided base translation in django/conf/locale is used as a fallback.
    ref: https://docs.djangoproject.com/en/4.2/topics/i18n/translation/#how-django-discovers-translations

For external Django apps like edx-enterprise , IMO the best approach is to use 2nd approach, which led to the creation of locale directory.
I should have remove conf/locale directory at this point, but I do not remember if I forgot to do so or if there was some other reason. I think we can remove this directory now if removing it does not cause any issues.

@iloveagent57
Copy link
Contributor

@shadinaif ping, reply above ^

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.

testing my new permissions, not a real review

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.

testing my new permissions, not a real review

@OmarIthawi OmarIthawi self-requested a review June 7, 2023 12:07
@shadinaif
Copy link
Contributor Author

Thank you @iloveagent57 !

@OmarIthawi OmarIthawi removed their request for review July 22, 2023 17:26
@mphilbrick211
Copy link

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

@shadinaif shadinaif force-pushed the shadinaif/FC-0012-OEP-58 branch 3 times, most recently from dfd34e8 to c88d9d0 Compare October 4, 2023 12:21
@shadinaif
Copy link
Contributor Author

shadinaif commented Oct 4, 2023

Thank you for the follow-up @mphilbrick211 , I'm testing it now to convert it into (Ready for review)

@mphilbrick211
Copy link

@shadinaif @iloveagent57 looks like tests need to be re-enabled.

@shadinaif shadinaif marked this pull request as ready for review November 12, 2023 10:02
shadinaif added a commit to Zeit-Labs/openedx-translations that referenced this pull request Nov 12, 2023
This PR needs openedx/edx-enterprise#1751 before it's merged.

Refs: FC-0012 OEP-58
shadinaif added a commit to Zeit-Labs/openedx-translations that referenced this pull request Nov 12, 2023
This PR needs openedx/edx-enterprise#1751 before it's merged.

Refs: FC-0012 OEP-58
shadinaif added a commit to Zeit-Labs/openedx-translations that referenced this pull request Nov 12, 2023
This PR needs openedx/edx-enterprise#1751 before it's merged.

Refs: FC-0012 OEP-58
shadinaif added a commit to Zeit-Labs/openedx-translations that referenced this pull request Nov 12, 2023
This PR needs openedx/edx-enterprise#1751 before it's merged.

Refs: FC-0012 OEP-58
shadinaif added a commit to Zeit-Labs/openedx-translations that referenced this pull request Nov 12, 2023
This PR needs openedx/edx-enterprise#1751 before it's merged.

Refs: FC-0012 OEP-58
@OmarIthawi
Copy link
Member

@iloveagent57 would you mind enabling tests one more time? It should be ready to merge.

@mphilbrick211 mphilbrick211 added the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Nov 14, 2023
Copy link

@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! Thank you!

@brian-smith-tcril brian-smith-tcril removed the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Nov 15, 2023
@brian-smith-tcril
Copy link

@iloveagent57 I'd like to merge this. You are listed as "please inform" on the spreadsheet. If there's any reason I should hold off please let me know, otherwise I'll plan on merging this tomorrow morning.

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.

I've tested it locally and it looks good to me. Thanks @shadinaif!

@brian-smith-tcril brian-smith-tcril merged commit 17b0857 into openedx:master Nov 17, 2023
8 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.

brian-smith-tcril pushed a commit to openedx/openedx-translations that referenced this pull request Nov 17, 2023
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.

6 participants