-
Notifications
You must be signed in to change notification settings - Fork 23
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: FC-0012 - add atlas support for cookiecutter-xblock #382
feat: FC-0012 - add atlas support for cookiecutter-xblock #382
Conversation
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. |
6dea480
to
ee8e819
Compare
779c81c
to
e11f8f6
Compare
e11f8f6
to
a738b8c
Compare
@@ -0,0 +1 @@ | |||
django.po |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OmarIthawi we have an issue here. Is it good enough to add the link in the template like this? or should we dig deeper to change the dependency of XBlocks on text
domain and change it to django
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep forgetting this @shadinaif, so it seems that you do too :)
In XBlocks we plan to store no po/mo files at all. The LMS will completely manage the translation e.g. edx-platform:conf/plugins-locale/drag-and-drop/conf/locale/django.po
.
So this link is not needed and could be harmful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shadinaif In case I didn't make myself clear, let's keep text.po
and textjs.po` as-is because those files will be irrelevant to all of the OEP-58 work and will eventually be removed from all XBlocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OmarIthawi thank you. What about developers creating new XBlocks? we've removed the part that converts the partial file into text.po
. Should we just add a comment to clarify that?
or maybe better: add an option in the cookiecutter creation to ask if the package is to be integrated with atlas, with default No
(because most usage would be from the community)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shadinaif if you must implement choices I recommend the following two options:
Option 1
Support both Atlas OEP-58 translation mechanism and the old way (like most XBlocks have been converted). The default choice.
The consequences here that we need make extract...
to support two modes:
make extract_translations
that produces text.po
and textjs.po
and make extract_translations
that produces django.po
and djangojs.po
.
Option 2
Support only Atlas and OEP-58. An optional but acceptable choice.
In my opinion Option 1 should be the only one available. After OEP-58 is finalized, we can move to Option 2 removing Option 1 altogether unless someone really wants to. Having options can be a bad Developer Experience especially when the consequences are not immediately obvious.
In either cases, we should enable an Atlas workflow as a mandatory feature in all new XBlocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @OmarIthawi , the case is confusing! the problem with the opposite is that openedx-tranlsations
will fail when it runs git add
when django.po
is the link. So, looks like we now have three options:
Option1: (the one I like): add an option in the cookiecutter creation to ask if the package is to be integrated with atlas, with default No (because most usage would be from the community). This supports two modes when creating the XBlock. U2 and partner developers who create XBlocks integrated with Atlas should simply be aware of the option
- Default (No): for the community, the translation is hosted somewhere else.
make extract_translation
command will look like this:
cd $(PACKAGE_NAME) && i18n_tool extract --merge-js --combine-partial --text-domain
(it means we add a new option--text-domain
toi18n_tools
to renamedjango.po
totext.po
on extraction)
the extracted file name will betext.po
- Support atlas (Yes): for atlas-supported XBlocks. No links are added too because
text.po
will not be used anyway.make extract_translation
command will look like the code we already have here:
cd $(PACKAGE_NAME) && i18n_tool extract --merge-js --combine-partial
the extracted file name will bedjango.po
Option2: add the link -s text.po django.po
and update openedx-translations
to deal with it. (complexity added to the script)
Option3: (simple but lazy from our side, we put the burden on others). always add the link -s django.po text.po
and let developers remove it manually when they know that the XBlock supports atlas
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shadinaif Atlas is not for 2U although they'll be using Atlas for sure.
OEP-58 is meant to benefit the wider community of Open edX. Therefore, we should make it enabled by default because the in-repo committed pofiles will be deprecated and removed. Therefore an option to enable Atlas doesn't make sense.
Thank you @OmarIthawi , the case is confusing! the problem with the opposite is that
openedx-tranlsations
will fail when it runsgit add
whendjango.po
is the link. So, looks like we now have three options:
Yeah, you're right. We're dealing with conflicting requirements here.
Both Option 2 and Option 3 are good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shadinaif Atlas is not for 2U although they'll be using Atlas for sure.
this is the main point I was missing! thank you @OmarIthawi
I'll go with Option2 then 👍🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OmarIthawi Update on Option2:
add the link -s text.po django.po and update openedx-translations to deal with text.po
and textjs.po
files when used by XBlocks. No links are added to the cookiecutter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! @shadinaif please remove the link from this PR.
@shadinaif https://pypi.org/project/edx-i18n-tools/1.2.0/ has been released so this PR is no longer blocked. |
a4e7dc8
to
4feaa3f
Compare
8597543
to
d55bab4
Compare
linter is failing when run locally, I'll fix it in a few |
d55bab4
to
975eb64
Compare
please review @OmarIthawi . See (How it was tested?) section in the PR description |
975eb64
to
2665a4d
Compare
@brian-smith-tcril @e0d would you mind approving this PR workflows to run tests? |
@@ -13,7 +13,7 @@ | |||
if __name__ == "__main__": | |||
os.environ.setdefault( | |||
"DJANGO_SETTINGS_MODULE", | |||
"{{cookiecutter.package_name}}.locale.settings" | |||
"{{cookiecutter.package_name}}.conf.locale.settings" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shadinaif Is it mandatory to have the settings.py
in locale
? Usually the locale
dir isn't expected to have any Python code.
My expectation is to find the setting in {{cookiecutter.package_name}}.dev_settings
or {{cookiecutter.package_name}}.locale_settings
if you must.
I understand that this pattern is already set, but it appears to be incorrect. Not a blocker though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shadinaif please take a look at this note.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used .dev_settings
not {{cookiecutter.package_name}}.dev_settings
, to place the file next to manage.py
(which uses the settings file)
8df4f21
to
1a702c2
Compare
Thanks @shadinaif. The pull request looks great! It looks good to me now. @itsjeyd @brian-smith-tcril please enable tests and review this pull request. |
@OmarIthawi Thanks for the ping! Looks like we've got a passing build 🙂 @shadinaif As far as I can tell from the PR description, this PR is part of FC-0012. Would you mind updating the title to reflect that? @brian-smith-tcril This is ready for final review/merge. Could you please take it from here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me. Thanks @shadinaif!
I've tested an earlier version of this PR and it worked. All my notes has been addressed :)
Thank you @itsjeyd , I changed the title |
@brian-smith-tcril copying from openedx/RecommenderXBlock#70 .
Good question @brian-smith-tcril . Here's why I recommended
Please let me know what's your thoughts. I'm okay with reverting back to |
I think my concern with |
Thank you @OmarIthawi and @brian-smith-tcril . I'll vote for
But actually, if I should decide that alone; I would name it
It is confusing in all cases in my opinion. What do you think? |
I think I still prefer It seems it should be easy to get I'm not sure what would be required to get the tests to do a similar thing, but I stand by not wanting to combine locale/dev/test settings together into one file. |
Update cookiecutter-xblock to support atlas for all new XBlocks Refs: FC-0012 OEP-58
1a702c2
to
043e2e6
Compare
Thank you @brian-smith-tcril and @OmarIthawi . I changed it to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good. I left 2 comments with questions about the changes in the json
, but nothing about those changes feels particularly problematic.
"github_org": "openedx", | ||
"repo_name": "{{cookiecutter.package_name}}-xblock", | ||
"tag_name": "myxblock", | ||
"repo_name": "{{cookiecutter.package_name.replace('_', '-')}}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is changing behavior
before this change, the value of repo_name
would be myxblock-xblock
, now it's my-xblock
is this change intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is intentional, I see it as more convenient to have the repo name the same as the package name unless the creator decides otherwise. No technical reason or implication for that
Note: the template will not enforce anything. It'll just propose these as defaults, and the XBlock creator can change them on the spot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another thing is that we have a new field i18n_namespace
that will look nicer by this change
"repo_name": "{{cookiecutter.package_name}}-xblock", | ||
"tag_name": "myxblock", | ||
"repo_name": "{{cookiecutter.package_name.replace('_', '-')}}", | ||
"tag_name": "{{cookiecutter.package_name|lower}}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to the comment about repo_name
- this will force _xblock
into tag names (considering there is now an expectation that _xblock
will be in the package name).
is this intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@jmbowman you're listed as "please inform" on the spreadsheet for this repo. I plan on merging this by EOD tomorrow. Please let me know if you have any objections. Thanks! |
@brian-smith-tcril I'm basically here as Jeremy's arch-bom representative on these translations/atlas tickets, just for future reference. |
@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. |
feat: add atlas support for cookiecutter-xblock
This PR prepares the repository to comply with openedx-translations by doing the following:
General:
post_gen_project
namedsymlink_translation
to create a symbolic link from./conf/locale
totranslation
Only for
cookiecutter-xblock
:i18_tool extract
to extract transactionslocale
toconf/locale
directory. This is the default used one in openedx-translationssymlink_translations
command fromMakefile
and use the newsymlink_translation
argument in post-generation hooki18n_namespace
instead of filling fixed name by the cookiecutter (default provided of course)How it was tested?
cookiecutter -o testdir cookiecutter-xblock
make upgrade
make requirements
git init && git add -A && git commit -m 'First commit'
to pass validation testsmake extract_translations
: everything looks finemake validate_translations
: no errorsReferences
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:
.json
,.po
or.mo
files will be committed into the repos.make extract_translations
in all repositoriesBreaking Changes
One of the primary goals of the project is to avoid breaking changes. If you notice any suspicious code, please raise your concern. But before that, please know the strategy we're following to avoid breaking changes
For XBlocks:
conf/locale
. Therefore, we are creating a link fromconf/locale
totranslations
so Atlas can find the path without disrupting the current way of having translations locally within the XBlocks