This repository was archived by the owner on Apr 17, 2026. It is now read-only.
Add support for ngettext#97
Merged
Merged
Conversation
Contributor
Author
|
@michaelDCurran and @seanbudd:
Note: I may also separate simple cases of |
Contributor
Author
|
@seanbudd, @michaelDCurran: |
Member
|
We'll talk about this internally early next week and get back with a
decision on if we want to proceed this way. Thanks for your ideas and
work on this.
|
Member
|
The plan looks good to us, feel free to go ahead with it |
Contributor
Author
|
Thanks @seanbudd. In this case, the first step is on your side: review and merge the current PR. |
seanbudd
reviewed
Jun 9, 2023
seanbudd
reviewed
Jun 13, 2023
seanbudd
approved these changes
Jun 13, 2023
seanbudd
left a comment
Member
There was a problem hiding this comment.
Thanks @CyrilleB79 for the explanation
6 tasks
seanbudd
pushed a commit
to nvaccess/nvda
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Links to issues:
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:
Changes in this PR
This PR adds the support of ngettext messages in the PO validation script.
Tests
Test 1
Run new
scripts/poChecker.pyon various files:nvda-61397_NOK_plural2_untranslated.po.txt
The files containing the plural string have been taken from SVN SRT repo when a first attempt to introduce ngettext in NVDA was made.
Test 2
Comparison of the output of the modified script with the output of the original one. The comparison has been made on the
nvda.pofiles of all languages available in SVN repo screenreadertranslations (commit 74391) as well as with all thenvda.pofiles available in the last master version of NVDA's Git repo (commit 96764959510a19d390f4493b78510df3a353cd50).The comparison has been made thanks to a test script made for this task.
Some diffs have been found in the order in which the placeholders are listed in the report, e.g.:
The placeholders are stored in a Python set in
scripts/poChecker.py, thus their order is not significant. I do not know however why the order has changed from one version ofscripts/poChecker.pyto another.Thus I have amended my test script to reorder alphabetically the placeholders in the output of
scripts/poChecker.pyso that we can ignore the order of placeholders on a same line.After this reordering post-processing, there was no diff between the outputs of the old and the new version of the script.
For reference here is the (quick and dirty) test script that I have used (updated and re-tested on June 9 2023):
launch_poChecker.py.txt