-
Notifications
You must be signed in to change notification settings - Fork 686
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
Improve pluralization of translated strings #5567
Conversation
Thanks @rmol test plan as described is passing, however encountered an error locally prior to updating the translations. Without the translations generated, an error is thrown (likely due to the name of the variables changing) but is being caught by the API error handler in https://github.com/freedomofpress/securedrop/blob/more-plurals/securedrop/journalist_app/__init__.py#L92:
Error handling here might warrant further investigation and/or we we consider strings as as part of this PR to support multiple languages in develop (prior to merging string changes). Right now, on this branch, using any other language than English on the source list of the journalist interface will result in error 500. |
I've updated the translations. There should be no more errors because of the changed strings, and in the next translation period, translators should only have to update the strings newly marked with |
(rebased on latest develop) |
Looks like translation tests are failing after the rebase on latest |
Switch a few strings containing numeric variables to ngettext from gettext, to ensure they can be properly translated. Use "num" more consistently as the placeholder for numeric variables in strings marked with ngettext, to make things easier for translators.
For languages with only one plural form, I've renamed the placeholders and removed the "fuzzy" mark from all updated translations in the .po files. Translators should not need to do anything for these at the next release. For languages with multiple plural forms: - For strings with changed placeholders that were already marked with ngettext, I've just updated the placeholders in the translations and removed the fuzzy marks. Translators should not need to do anything for these. - For strings newly marked with ngettext, I updated the placeholders but left the translations marked fuzzy, so Weblate should show them as needing editing, and translators will have a chance to correct the new plural versions.
In translation-test, unlike run and run-test, REPOROOT isn't used. As it is required a couple of times in dev-deps, ensure that it is set and available to all the functions there, without overriding any existing value in the environment.
I think it was actually my fix for Redis dump file version incompatibility. The |
Nope, after rebasing, also had problems running the newly-type-hinted |
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.
Thanks @rmol looks good to me, went through the diff and the functional test of the translations:
- Visit the journalist interface, switch to your test language, and ensure that the strings are being translated correctly:
- Enter a HOTP secret a few characters long.
- Enter less than three characters in the username field.
- Enter more than 100 characters in the first and last name fields.
- Pressing add user should result in properly-translated error messages.
- Visit the source list and verify that the document, message, and unread counts are being properly translated. You'll need to submit a single file and document as a new source to test singular translations.
- Delete a single source from the source list. The
{num} collection deleted
message should be properly translated. - Delete more than one source from the source list. The
{num} collections deleted
message should be properly translated. - Delete a single source submission. The
Submission deleted
flash message should be properly translated. - Delete more than one source submission. The
{num} submissions deleted
flash message should be properly translated.
I've noticed that for cs
, ro
, ru
and sk
, the fuzzy
attribute is preserved in the translations of the strings that were touched. was this intentional?
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.
Approving based on previous review, as discussed fuzzy translation for those four languages is expected.
Status
Ready for review
Description of Changes
Switch a few strings containing numeric variables to
ngettext
fromgettext
, to ensure they can be properly translated. Use "num" more consistently as the placeholder for numeric variables in strings marked withngettext
, to make things easier for translators.Fixes #5566.
Testing
git checkout -b more-plurals origin/more-plurals
make translate
de_DE
and edit its.po
file (securedrop/translations/de_DE/LC_MESSAGES/messages.po
) to find the updated source strings, remove thefuzzy
markers, and correct the placeholder names..po
file's directory, runmsgfmt messages.po
.make dev
.{num} collection deleted
message should be properly translated.{num} collections deleted
message should be properly translated.Submission deleted
flash message should be properly translated.{num} submissions deleted
flash message should be properly translated.Deployment
The updated strings will need to be translated at the next release. Until then, they'll always appear in English.
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: