hedyorg / hedy

Hedy is a gradual programming language to teach children programming. Gradual languages use different language levels, where each level adds new concepts and syntactic complexity. At the end of the Hedy level sequence, kids master a subset of syntactically valid Python.
https://www.hedy.org
European Union Public License 1.2
1.32k stars 289 forks source link

[BUG] Shared program view UI is always in Frysk #1371

Closed TiBiBa closed 2 years ago

TiBiBa commented 2 years ago

Describe the bug Currently when opening a shared program by share link the page will always be loaded in the Frysk language. When switching languages only the menubar changes correctly (expect the my profile page for some reason) but the rest of the UI stays at Frysk. This might be an issue with the fallback language for this page where we always return Frysk.

Visit, for example: https://www.hedycode.com/hedy/69a752cc91b441be96c55c4d299f4f6a/view?lang=nl

Add a screenshot (optional) Schermafbeelding 2021-11-24 om 10 44 11

Expected behavior The viewed program should correctly display the language of choice in the menubar and the program view UI.

What machine and browser you were using (optional) If the issue concerns things in the website, let us know:

Felienne commented 2 years ago

Haha, weird!! The fallback should work the other way around (Frysk falls back to Nl instead of En as other langs do) but guess something is amiss here.

@rix0rrr do you know what went wrong here? This surely has not always been like this. Might #1266 have something to do with it?

TiBiBa commented 2 years ago

I think I've found a fix! It seems that the translations on the @app.route('/hedy/<id>/view', methods=['GET']) are retrieved with the lang variable. For some reason this variable is always fry. However, we should (as is consistent with other templates rendering) use the g.lang variabel which does contain the correct value. I don't know how/why/when we should use the lang value, but it exists for some reason.

By changing lang into g.lang on lines 845 and 848 in app.py the issue should be fixed!