Skip to content
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

Plural forms should be reported with correct grammar #12445

Closed
CyrilleB79 opened this issue May 20, 2021 · 2 comments · Fixed by #15864
Closed

Plural forms should be reported with correct grammar #12445

CyrilleB79 opened this issue May 20, 2021 · 2 comments · Fixed by #15864
Milestone

Comments

@CyrilleB79
Copy link
Collaborator

I open this issue since:

Steps to reproduce:

  • Go to a web page with lists, e.g. this issue:
  • Arrow down to a list with one item, e.g. the example list below:
    • Example list item
  • Listen what is reported

Actual behavior:

"List with 1 items" is reported.

Expected behavior:

"List with 1 item" is reported (no 's' to 'item')

System configuration

NVDA installed/portable/running from source:

source

NVDA version:

last alpha

Windows version:

10

Name and version of other software in use when reproducing the issue:

Other information about your system:

Other questions

Does the issue still occur after restarting your computer?

yes

Have you tried any other versions of NVDA? If so, please report their behaviors.

Same issue in 2020.4

If add-ons are disabled, is your problem still occurring?

yes

Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?

N/A

Implementation strategy

In initial description of #12432, @feerrenrut wrote:

We use ngettext in one location, essentially a trial for now.

Since the use of categories for Outlook calendar items impact few people, I would recommend:

  1. Make a PR against beta introducing another test message with plural form more widely used. "List of n items" could be used.
  2. Make a PR for 2021.2 for the remaining simple forms (only one value in the message)
  3. Make a future separate PR for the more complex forms that may need to split the messages such as "table with x rows and y columns"; a gramatical analysis is required in order to know how to split the strings for this case.

A rapid estimation let me think that about 38 messages are concerned with plural forms.

@feerrenrut would you accept the first PR against beta to make a wider test?

@CyrilleB79
Copy link
Collaborator Author

Since the only use of ngettext was removed in #12448, the implementation strategy could be as follows:

  1. Fix the issue in the checkPot caused by the use of ngettext (cf. Fix-up of #12432: Fix key error when reading appointment with categories #12435 (comment)); @feerrenrut, @michaelDCurran could you elaborate on the encountered issue? (link to a failed checkPot)
  2. Use ngettext for the simple cases (the majority), i.e. the messages containing only one value that can trigger a plural form.
  3. Use ngettext for more complex messages that need to be split in more simple messages.

Distinguishing the two last steps in two separate PRs may allow to revert only the last PR if issues are encountered when splitting complex strings.

Since all occurrence of ngettext has been removed from NVDA 2021.1 beta branch, we can now handle these three PRs in alpha branch without problem and without emergency.

@feerrenrut
Copy link
Contributor

These errors occurred in the translation system. In response to a translator making a commit to the ScreenReaderTranslations repository (hosted on assembla), the *.po file is checked with a custom poChecker.

We noticed messages such as the following going to many translators:

surveyor committed Changeset [61438]: small fixes

small fixes

Files Affected:
M /tr/nvda.po

Files count: 1
Commit (by surveyor)


File /home/nvdal10n/mr/srt/tr/nvda.po: 1 error

Message starting on line 7190
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}

Note that the original is about start time, the translated was about categories. Similar error messages (all referencing categories) were being seen for many commits by different translators.

seanbudd pushed a commit to nvaccess/mrconfig that referenced this issue 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.
seanbudd pushed a commit that referenced this issue 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`
seanbudd pushed a commit that referenced this issue Dec 8, 2023
Closes #12445
Follow-up of #15013.

Summary of the issue:
When possible NVDA needs to distinguish between singular and plural in UI messages. The impact may be more significant in languages such as Slavic ones, where there are more than one plural form.

Description of user facing changes
In NVDA UI messages, i.e. in GUI or when NVDA speaks or brailles messages, messages will use singular/plural form as needed.

Description of development approach
Look for all strings containing "%" or "{" in the .pot and check if a plural form is needed. And replace _ / pgettext by ngettext / npgettext where needed.
Some expression containing a number have been pluralized even if they do not differ between singular and plural form in English due to the difference being visible in translations due to a different grammar. E.g.: "{numFingers} finger {action}" in English to be translated to "{action} {numFingers} doigt" (singular) vs "{action} {numFingers} doigts" (plural) in French.
table-rowcount and table-columncount control fields of the virtual buffer's text info have had to be converted to integer (previously strings), so that computation can be done.
No change log needed except for the code's API breaking change.
Testing strategy:
Manual smoke test on a subset of strings.
Feedback from translators during translation period and communication with the translators mailing list
@nvaccessAuto nvaccessAuto added this to the 2024.1 milestone Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants