Remove one and only use of ngettext for now#12448
Merged
Merged
Conversation
…etting confused by it, and this was not the first and only issue.
seanbudd
approved these changes
May 21, 2021
Contributor
seanbudd
pushed a commit
to nvaccess/mrconfig
that referenced
this pull request
Jun 13, 2023
Preliminary to nvaccess/nvda#12445 Context A first use of ngettext had been introduced in NVDA in nvaccess/nvda#11598 and nvaccess/nvda#12432. However these changes were removed in nvaccess/nvda#12448. Issue As written by @michaelDCurran in nvaccess/nvda#12448: However, it seems that our PO validation code in the translation system is not handling plural forms well, and is incorrectly classing translations as missing brace format variables, as it is incorrectly comparing the translation with the message before that one. It then outputs the following error: Message starting on line 7169 Original: "{startTime} to {endTime}" Translated: "category {categories}" Error: missing brace format interpolation, extra brace format interpolation Expected: these brace format interpolations: {endTime}, {startTime} Got: these brace format interpolations: {categories} Changes in this PR This PR adds the support of ngettext messages in the PO validation script.
CyrilleB79
added a commit
to CyrilleB79/nvda
that referenced
this pull request
Jun 13, 2023
… to be getting confused by it, and this was not the first and only issue. (nvaccess#12448)" This reverts commit 76fc1f7.
CyrilleB79
added a commit
to CyrilleB79/nvda
that referenced
this pull request
Jun 15, 2023
… to be getting confused by it, and this was not the first and only issue. (nvaccess#12448)" This reverts commit 76fc1f7.
6 tasks
seanbudd
pushed a commit
that referenced
this pull request
Jun 19, 2023
This PR is the first step to reintroduce the distinction of singulare/plural forms when formatting UI strings. The project is as follow: 1. This PR introduce three strings to be able to test the feature. 2. 2023.2 beta phase should be used to validate more widely the feature with translators 3. A second PR during 2023.3 dev cycle will implement the plural forms for all UI strings containing only one value to format them. 4. A third PR should implement more complex cases of string formatted by two or more values, e.g. such as "table with x rows and y columns". This step-by-step approach should allow to lose less work in case an issue occurs and requires to revert changes. ### Link to issue number: First step to implement #12445. Restoring #11598, #12432 and #12435 that were reverted in #12448. Unblocked by nvaccess/mrconfig#97. ### Summary of the issue: Some UI messages or strings are reported with plural form, no matter the number passed as parameter to format them, e.g. NVDA reports "list with 1 items" with "s" even if there is only one item. ### Description of user facing changes The following strings will be reported using singular or plural form depending on the number used to format them: * "with %s items" (used to describe the number of items in a list on the web) * ".1f lines" (used when reporting multiple line spacing formatting in MS Word) * ""categories {categories}" used to report categories of appointments in MS Outlook Translators will be able to translate singular or plural forms. ### Description of development approach * First revert #12448 to restore the first attempt that was made to introduce `ngettext`. * Develop a custom `npgettext` function the same way as `pgettext` was introduced in NVDA since `npgettext` is not available in Python 3.7; `pgettext` and `npgettext` are available natively in Python 3.8. * `ngettext` and `npgettext` are made accessible without importing them; `pgettext` was already added previously in builtins. * Implement the plural form for two strings that are more commonly used than Outlook appointments category reporting: * "with %s items", using `ngettext` * "%.1f lines", using `npgettext`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
None
Summary of the issue:
Recently NVDA began using ngettext to allow translators to provide both singular and plural translations for a particular message.
However, it seems that our PO validation code in the translation system is not handling plural forms well, and is incorrectly classing translations as missing brace format variables, as it is incorrectly comparing the translation with the message before that one.
It then outputs the following error:
ngettext was so far only used for one string in NVDA, in source/appModules/outlook.py. Seen by doing
git grep ngettext.We have many many strings in NVDA which would benefit from ngettext, but we need to know it works correctly. So until we are sure we can validate this correctly, we should stop using it in the one and only place it exists today.
Description of how this pull request fixes the issue:
Stop using ngettext for the one string in the Outlook appModule, instead replacing it with a normal use of
_()providing just the plural form.Testing strategy:
Known issues with pull request:
None.
Change log entries:
None needed.
New features
Changes
Bug fixes
For Developers
Code Review Checklist: