-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
fix: Fix invalid ngettext usage #9560
base: master
Are you sure you want to change the base?
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.
can you please share the output of before and after this change?
That's very good question, because it got me thinking... And turns out, I missed important detail. In our production code, we override this class with extra = ngettext(
"Try again later in about {wait} second",
"Try again later in about {wait} seconds",
wait,
).format(wait=wait) To fix, invalid usage of "second[s]" in languages with three plural forms (like Ukrainian or Russian). I don't see translations for this string in current DRF, and English has only two plural forms, so there would be no changes at all. Proper way to fix it, would be the same, and i'm pushing updated changes. Expected changes in Ukrainian, after this change lands, after updating .po with -"Спробуйте ще раз через 5 секунди"
+"Спробуйте ще раз через 5 секунд" Because we have three plural forms:
|
@auvipy please take a look at this again. |
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.
is their anyway you can ensure that this won't create any regression, please?
Format should be called after ngettext. If you have overridden `extra_detail_singular` or `extra_detail_plural`, you should now replace them with a single `def extra_detail` override. Refs: https://docs.djangoproject.com/en/5.1/topics/i18n/translation/#pluralization
582fb95
to
76cc34a
Compare
This code is covered by tests, and translation strings is unchanged, so everything should be fine. We probably need to make sure changelog is clear about what's changed here. I have squashed commits and updated text, but if changelog is autogenerated from the first line of commit, you may need to move relevant instructions into the first line when Merging/Squashing. Important part there: "If you have overridden |
Description
Format should be called after
ngettext
, not before.See example: https://docs.djangoproject.com/en/5.1/topics/i18n/translation/#pluralization
Formatting changes is because i don't know how to properly format it with your previous style, and there's no included autoformat/or formatting linter. I just formatted it automatically with ruff-lsp. Feel free to revert fomatting changes to your style or explain me what to do.