openwebwork / webwork2

Course management front end for WeBWorK
http://webwork.maa.org/wiki/Main_Page
Other
142 stars 165 forks source link

langage from the course is not rendered in simple template #1378

Open jutrembBDEB opened 3 years ago

jutrembBDEB commented 3 years ago

I’m working on a project of translating some pretext book in french, like Active Calculus. We have our own WeBWorK server and I succeded in converting the book in html. Everything works fine, except the interface (buttons, message, etc) of the webwork exercices is always in english, even though my course configuration is set in french (fr-CA)

What i think I understand is that in WeBWorK, the FormatRenderedProblem.pm is suppose to rendered the WeBWorK problem in the simple format, but localization to french is not working.

$formLanguage = ($self->{inputs_ref}->{language})//'en';

This $formLanguage variable is suppose to contain the language, but is set automatically to « en » because language is empty.

My server is 2.15, but @Alex-Jordan just tested with a 2.16 server and he have the same behavior.

drgrice1 commented 3 years ago

To set the language you will need to add the language argument to the url. So the url should look something like https://.../webwork2/...?sourceFilePath=...&language=fr-CA.

Alex-Jordan commented 3 years ago

OK, @jutrembBDEB I can make it so that PreTeXt attaches that to the URLs we use. Funny, I tried this earlier today, just shooting in the dark, but I tried lang instead of language.

mgage commented 3 years ago

Did this resolve the problem? supposedly maketext is being used to translate the buttons in FormatRenderedProblem.pm (see lines 243 and following) https://github.com/openwebwork/webwork2/blob/WeBWorK-2.16/lib/FormatRenderedProblem.pm#L246

Alex-Jordan commented 3 years ago

@drgrice's answer resolves @jutrembBDEB's question.

For the use case, I need to add a feature to PreTeXt, but that's not for this forum.

One thing though, the French localization file needs updating. If I use: https://webwork-ptx.aimath.org/webwork2/html2xml?&problemSeed=1&answersSubmitted=0&sourceFilePath=Contrib/PCC/BasicAlgebra/QuadraticEquations/solveQuad90.pg&displayMode=MathJax&courseID=anonymous&userID=anonymous&course_password=anonymous&outputformat=simple&language=fr

(or with fr-FR or fr-CA)

then "Preview My Answers" and "Show Correct Answers" are still in English. @jutrembBDEB, would you be up for updating this? It is at: https://github.com/openwebwork/webwork2/blob/WeBWorK-2.16/lib/WeBWorK/Localize/fr.po

Looks like "Preview My Answers" is new, and "Show Correct Answers" used to be "Show correct answers".

drgrice1 commented 3 years ago

I think the localization pot and po files need to be updated again for the final release.

jutrembBDEB commented 3 years ago

Their is one po file that is name fr_CA in my repo. Does it need to be change to fr-CA? I can make that change easily! The fr.po is not up to date with the translation, i worked on translating the fr_CA file, but i can see that it doesn’t exist in the 2.16 branch.

Still the "Show correct Answer" need to be corrected to "Show Correct Answer".

jutrembBDEB commented 3 years ago

It looks like there is an issue related to the one I summited in the 2.16 branch. In the library browser or the problem set details pages, when we render the problems, the langage is set on en-US. Now that I know that we have to pass the langage attribute in the html, I didn't find a way to do so in localOverides.conf. The FormatRenderedProblem.pm file doesn't take any langage parameters from the course, so how can I pass my langage attribute?

I found a tempory solution to the problem. I edited the file problemsetdetail.js and setmaker.js to add my langage attribute just before the render() function.

var language = $('#hidden_language').val();
var basicWebserviceURL = "/webwork2/html2xml?&language=" + language;

And I added an hidden CGI in the files SetMaker.pm and ProblemSetDetail.com to pass my langage from the course CGI::hidden({id=>'hidden_language',name=>'language',value=>$ce->{language} }),

I'm sure this solution may not be what you would have done or maybe I forgot to do something in my conf files?

drgrice1 commented 3 years ago

We can obtain both the course language and the direction from document.documentElement.lang and document.documentElement.dir (if defined) in the javascript. Those are set from the course settings already. That requires no modification to SetMaker.pm and ProblemSetDetail.pm.

Edit: Actually we don't need the direction as it is determined from the language in format rendered problem.

drgrice1 commented 3 years ago

Also, the basicWebserviceURL should not be modified. Instead the appropriate ajax data parameters should be set.