lookit / lookit-api

Codebase for Lookit v2 and Experimenter v2. Includes an API. Docs: http://lookit.readthedocs.io/
https://lookit.mit.edu/
MIT License
10 stars 18 forks source link

Fix nav button translations #1379

Closed becky-gilbert closed 5 months ago

becky-gilbert commented 5 months ago

TL;DR

This PR fixes a problem with the navigation bar button labels not being translated. The problem was related to how we were generating the navigation bar buttons, which was causing Django to not pick up the button text as needing translation.

Description

While testing the translation updates, I noticed that some of the navigation bar button labels weren't being added to the translation (.po) files. A while ago we changed the way that we create the nav buttons in the templates (with a custom nav_link template tag) but it turns out that translating the text within that template tag meant that the text wasn't being picked up by Django and added to the .po file. This fixes the problem by translating the text in the template first, before passing the translation as an argument into the nav_link tag. I also re-generated all of the .po files so that they include the navigation bar button labels - the updated file versions are included in this PR.

Screenshots

Before this change, most of the navigation bar button labels were not being picked up for translation. Here is a screenshot from the develop branch in Japanese, which uses our most up-to-date translation file:

Screenshot 2024-04-10 at 3 42 25 PM

The text for the untranslated buttons (CHS Home, FAQ, The Scientists, My Account, My Past Studies) does not exist in the .po file (vs existing in the file but not containing a translation value).

After the changes in this PR, the navigation button labels are being picked up for translation and added to the .po files. (For this screenshot, I was able to set some actual Japanese translations using fuzzy/suggested values, and then I just put in some "TEST" placeholder values for the others that were empty.)

Screenshot 2024-04-10 at 3 40 00 PM

Implementation notes:

I realize this is less elegant than translating the text argument inside the template tag, because now we have to have a bunch of separate lines in the templates to store each translation string. I did try a few different ways of translating the text inside the nav_link code but couldn't get that approach to work.

becky-gilbert commented 5 months ago

This PR has picked up the linting errors that were merged in from develop, so I'll wait for those fixes to be merged in, and then I'll update this PR to sync with develop again.

sonarcloud[bot] commented 5 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud