-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix: disable video status translation for JSON endpoint #33939
fix: disable video status translation for JSON endpoint #33939
Conversation
Thanks for the pull request, @CefBoud! 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. |
f61a071
to
154bb67
Compare
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.
@CefBoud While the solution works as you have outlined, I find passing skip_translation
around so many functions suboptimal. While skip_translation
is the appropriate variable name for the StatusDisplayStrings
class, it might have to become skip_video_status_translation
in places like _get_videos
to avoid confusions relating to transcripts and translations.
So I am really trying to avoid it.
Taking a step back, the translations are required only for presentation purposes, which means, it's the responsibility of the presentation layer (HTML templates) to render the correct strings. That seems to be the case in the one instance I found using the status
attribute. So, it is possible that just removing the _()
gettext call Line 178 alone might be sufficient.
Can we check if that would be a valid solution? Identify the places where the status
is used in the templates, underscore, and JS ..etc., and check if it is wrapped with an i18n call? If not, wrap it and remove the translation from the StatusDisplaySettings
?
Note:
- Extra Languages can be added by configuring the Dark Language config. I added
en,fr,es,de
as supported values andEnglish
andFrench
showed up in my Account Settings page. I am guessing Spanish and German are beta-languages.
@tecoholic Thank you for the review.
This could work. However, may I bring your attention to the fact that the instance you linked to relates to the active/uploading statuses defined in the frontend and for which translation is available in djangojs.js files unlike the statues impacted by this PR for which translation is only availbale in django.po files. Therefore, please correct me if I am wrong, PS: thanks for the language tip, it worked splendidly. |
154bb67
to
62bf2e7
Compare
@CefBoud Ah! I see. I knew my lazy searching was leaving things out. I didn't realize I had the completely wrong one. I want to ask someone with better knowledge of the system to see if there is a way to make this simpler. @Agrendalath Can you kindly take a look here? Do you see a way to avoid passing |
@tecoholic, @CefBoud, I see this code for the first time, so I do not have the full context. Do I understand correctly that we must keep the translated string because some existing platform's code relies on it? Will this code be removed later, during removing the legacy views that the MFEs will replace? If this is the case, we could return both values, i.e., |
I am not aware of the roadmap regarding the removal of legacy views. TL;DRThe Problem
The solution so far
The counterproposal
|
@CefBoud, using the # The MFEs handle translating the status on their own, so we can remove the second line once the legacy views are deleted.
video['status_nontranslated'] = convert_video_status(video, is_video_encodes_ready)
video['status'] = _(convert_video_status(video, is_video_encodes_ready)) This way, the MFE could use It would also be fully backward-compatible.
This is also doable, but IMHO it will introduce more code duplication, as we would need to duplicate these statuses in JS to generate the translation strings for them. |
0c492ff
to
7585726
Compare
Thank you for further explaining your suggestion. I love it !!! It amounts to very little change and I feel the introduction of the new CC @tecoholic |
eae81ba
to
66b17e9
Compare
66b17e9
to
7d4c21f
Compare
@CefBoud 👍
|
I don't have a Jira project configured for this repo in the private 2U Jira. Contact Ned Batchelder (@nedbat) to set up a project. |
@jristau1984 @cablaa77 This is related to the Video Upload block, where the filtering breaks for non-English users. |
@mphilbrick211 any update on the review on this PR? |
@CefBoud 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
2U Release Notice: This PR has been deployed to the edX production environment. |
1 similar comment
2U Release Notice: This PR has been deployed to the edX production environment. |
Description
This PR is related to GET /videos endpoint in JSON format. It disables server-side translation for this format. This endpoint is consumed by frontend-lib-content-components which is used by
frontend-app-course-authoring
.The usecase is a Video Gallery that lists videos and enables the user to filter by video status. The issue arises from the fact that the statuses returned by this endpoint are already translated which makes comparing their values to the filter's predefined values problematic.
The changes introduced here only disable translation but still send the English human-friendly string instead of the canonical status values because there is a one-to-many relationship between the status formats. For instance
Failed
maps to multiple canonical statues:file_corrupt
,pipeline_error
, etc. So sending the canonical statues would require duplicating those mapping which is far form ideal. Thus, considering that the English human-friendly status as a reference to be filtered against (and manipulated in other different ways) seemed like a reasonable trade-off.Supporting information
Private ref: BB-8076
Testing instructions
make dev.up.cms
4.Modify def handle_videos to always return json to facilitate testing from the browser.
Head to Course Videos in Django Admin and create some course videos for the Demo course. Use the Devstack provisionned videos.
Head to http://localhost:18010/videos/course-v1:edX+DemoX+Demo_Course. You should see a json of the Course Videos you created.
Head back to Course Videos in the admin panel and edit the status of the Video that your Course Video links to. You must use canonical values. Set status to
ingest
orupload_failed
which will map toIn Progress
andFailed
respectively.Head to your account and change your language setting. (For some reason, only English was showing in my case. I simply changed the value of the Option HTML tag to
fr
instead ofen
and it worked.)Before applying the changes in this MR, the video status would be translated. After applying it, it is not.
Apologies for the convoluted instructions.