MCKIN-21527 Problem Builder (FTE, Assessment, MCQ, MRQ) - On opening these modules, none of the text is translated on notifications dropdown. - #298
Conversation
| var data = $('.attempts', element).data(); | ||
| $('.attempts', element).html(attemptsTemplate(data)); | ||
| if (data != undefined && data.max_attempts > 0) { | ||
| var message = _.template( |
There was a problem hiding this comment.
Please note that template string is now pulled out of mentoring_attempts.underscore because it was using global ngettext but we require local problem builder ngettext for translation.
…these modules, none of the text is translated on notifications dropdown.
|
@xitij2000 Please review this Pull Request |
xitij2000
left a comment
There was a problem hiding this comment.
👍 This is good to merge once the review comments have been addressed.
This should also come with a corresponding v4/master PR.
- I tested this: tested with multiple languages, present, not present, with and without a dash
- I read through the code
| function renderAttempts() { | ||
| var data = $('.attempts', element).data(); | ||
| $('.attempts', element).html(attemptsTemplate(data)); | ||
| if (data != undefined && data.max_attempts > 0) { |
There was a problem hiding this comment.
This seems to be duplicated. The template is already performing this check.
There was a problem hiding this comment.
Removed the template!
| ngettext("You have used {num_used} of 1 submission.", "You have used {num_used} of {max_attempts} submissions.", data.max_attempts), | ||
| {num_used: _.min([data.num_attempts, data.max_attempts]), max_attempts: data.max_attempts}, {interpolate: /\{(.+?)\}/g} | ||
| ); | ||
| data.message = message; |
There was a problem hiding this comment.
message is defined inside the if, but used outside.
There was a problem hiding this comment.
message is used within the if statement,
Update Problem builder v3 from OC
|
@xitij2000 , Version 4 Pull Request https://github.com/open-craft/problem-builder/pull/295/files |
MCKIN-21527 Problem Builder (FTE, Assessment, MCQ, MRQ) - On opening these modules, none of the text is translated on notifications dropdown.
Based on the Previous Closed Pull Request comments #294
@wasifarbisoft I just tested this from scratch, and I don't think this approach will work. While it does solve the problem from browser side, it breaks extracting translations. I think the best approach here is to make the gettext and ngettext declaraton from being global to local to the function, instead of renaming them everywhere, which would mean that translations can no longer be extracted because the tooling searches for gettext not pb_gettext.