-
Notifications
You must be signed in to change notification settings - Fork 687
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
Correct untranslated messages #5881
Conversation
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.
this looks great! i left some comments that i'll provide now. i still need to run through the test plan before i can approve.
Correct some misplaced parentheses in gettext/format calls. Mark some strings that were being presented untranslated. Fix locale/session handling on CSRF error. We were translating the CSRF error message, then clearing the session and showing the rest of the page in the default locale, almost certainly English. We need to reevaluate how we want to handle the locale when clearing the session, but for now, this just fixes the inconsistency.
We haven't really been testing translations. In the page layout tests, the content of strings is often only checked after making sure the page is *not* translated. This has led to us not catching text which didn't get marked for translation, thus being shown in English to users who are using a different locale. This commit includes the following changes to make it easier to test that source strings are properly translated: - a context manager which will xfail a test for a locale if any of the message IDs passed to it are not present in the locale's message catalog - a pytest flaky filter which prevents retries of expected failures - turning off flaky's reporting of successful tests - functions to obtain test locales and counts to use in testing their pluralization rules, which can be used with pytest.parametrize to easily run a test in multiple locales, including fuzzing plural strings to check that translations are complete, while only trying as many variations as the rules need. Adding locale parameterization to tests increases the overall time they take, of course: test_journalist.py went from around 2.5 minutes to 3.5 minutes.
@rmol this message "Name not updated: Name too long" should be in French, right? |
Yes it should. I left a crucial step out of the test plan. The French message catalog needs to be edited to translate the new messages, and the dev server restarted. I've updated the test plan, sorry about that. |
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.
works great with the gist you provided for French translations:
Status
Ready for review
Description of Changes
Fixes #5755.
Corrects some misplaced parentheses in gettext/format calls. Marks some strings that were being presented untranslated.
Fixes locale/session handling on CSRF error. We were translating the CSRF error message, then clearing the session and showing the rest of the page in the default locale, almost certainly English. We need to reevaluate how we want to handle the locale when clearing the session, but for now, this just fixes the inconsistency.
Adds localization checks to basic source/journalist interface tests. We haven't really been testing translations. In the page layout tests, the content of strings is often only checked after making sure the page is not translated. This has led to us not catching text which didn't get marked for translation, thus being shown in English to users who are using a different locale.
Includes the following changes to make it easier to test that source strings are properly translated:
Adding locale parameterization to tests increases the overall time they take, of course: test_journalist.py went from around 2.5 minutes to 3.5 minutes.
Testing
Application string changes
git checkout develop
make dev
Journalist interface
<code>
tag, so that it is displayed in a fixed-width typeface. (This is just checking that the formatting wasn't broken by reorganizing the translation.)chmod 555 securedrop/static/i
git checkout -b fix-5755 origin/fix-5755
.securedrop/translations/fr_FR/LC_MESSAGES/messages.po
with the test translations in this gist.Source interface
curl -sH "X-tor2web: encrypted" 'http://localhost:8080?l=fr_FR' | grep Tor2Web
should produce:Deployment
This is mostly changes to text or tests. The string changes should correct several cases of English messages being shown to people who've chosen another locale. There are a couple of changes to messages that wind up in logs; the new messages record less information.
Checklist
If you made changes to the server application code:
make lint
) and tests (make test
) pass in the development containerIf you made non-trivial code changes:
Choose one of the following: