-
Notifications
You must be signed in to change notification settings - Fork 70
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
[MCKIN-2723] Use i18n runtime service to provide translations for HTML templates #154
[MCKIN-2723] Use i18n runtime service to provide translations for HTML templates #154
Conversation
84fd843
to
0bec8ef
Compare
drag_and_drop_v2/drag_and_drop_v2.py
Outdated
'js_templates': js_templates, | ||
'id_suffix': id_suffix, | ||
'fields': self.fields, | ||
'self': self, | ||
'data': urllib.quote(json.dumps(self.data)), | ||
} | ||
}) | ||
|
||
fragment = Fragment() | ||
fragment.add_content(loader.render_template('/templates/html/drag_and_drop_edit.html', context)) |
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.
Can we change from render_template
to render_django_template
while we're at it? The former is deprecated since it's ambiguous in an XBlock context.
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.
Fixed with a79afd7.
a79afd7
to
c9dbe04
Compare
@pomegranited Currently adding a new DnDv2 block to a course is broken, which is why tests on https://github.com/edx/edx-platform/pull/17670 are failing. This does not seem to be related to this PR, but rather a recent change we made to this xblock. Apparently the line that was removed is still needed and the comment mentioning Dogwood was wrong. Can you please add it back in? Other than that I tested this and it seems to be working great, but some translations are missing (see screenshots below). It seems that most of the missing translations are from js_templates.html, which for some reasons uses I also noticed that the |
Oo, thank you for figuring out why those tests were failing! Re-added that line with 9bf377e.
The js_templates.html are JS Handlebars templates, and they were supposed to use this So I've submitted deea454, which converts the
I updated that with this PR to add the compiled |
FYI: I've re-added the "WIP" to the title so we don't forget to merge and tag openedx-unsupported/xblock-utils#48 first. |
@@ -716,6 +716,7 @@ function DragAndDropBlock(runtime, element, configuration) { | |||
var renderView = DragAndDropTemplates(configuration); | |||
|
|||
var $element = $(element); | |||
element = $element[0]; // Works around this Studio bug: https://github.com/edx/edx-platform/pull/11433 |
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.
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.
Not fussed here -- @mtyaka which method would you prefer?
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 slightly prefer the restored approach, but am fine with either.
I still think the root cause is a bug in edx-platform. It sometimes initializes the xblock with a jquery object and sometimes with a plain DOM element.
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.
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 still think the root cause is a bug in edx-platform. It sometimes initializes the xblock with a jquery object and sometimes with a plain DOM element.
It is, but unfortunately when we've tried to fix it at the platform level, new things broke.
Thanks @pomegranited!
Sorry about that - I did not realize the strings in js_templates.html were supposed to be translated by JS and not by django. Since it's JS translations which do not work in xblocks at all as far as I can tell, and we'll probably have to fix that anyway, it might make sense to revert the changes until we fix JS translations properly. |
👍
|
deea454
to
9bf31fe
Compare
to take advantage of template translations from openedx-unsupported/xblock-utils#48 Bumps version to 2.1.6
9bf31fe
to
4aeb0f7
Compare
Squashed 49cf04b...9bf31fe into 4aeb0f7 to make it cleaner to use this change on the client's fork. |
c8f57e7
to
2f68651
Compare
@sanfordstudent All our dependent PRs have merged, so this PR is ready for review. (Yay!) |
Thank you @sanfordstudent ! Merging now. |
Once the dependent PRs are merged, this change is all that's required to allow this XBlock to use its own translations for text found in HTML templates.
JIRA tickets: MCKIN-7023, OSPR-2289
Discussions: WL-230, YONK-879
Dependencies:
Screenshots:
Before
these changes, the only text in DnDv2 HTML templates that would appear translated were the text that happened to be translated in edx-platform.
After this change, DnDv2 template translations like this one appear in Studio and LMS:
Sandbox URL: (841a68c)
Merge deadline: None
Testing instructions:
/update_lang
appended, and submiteo
as your selected Language Code.blocktrans
andtrans
template tag strings appear translated.Author notes and concerns:
Reviewers