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

Python format check not applied to some plural forms #9682

Closed
2 tasks done
VladimirSlavik opened this issue Aug 3, 2023 · 7 comments · Fixed by #9695
Closed
2 tasks done

Python format check not applied to some plural forms #9682

VladimirSlavik opened this issue Aug 3, 2023 · 7 comments · Fixed by #9695
Assignees
Labels
enhancement Adding or requesting a new feature.
Milestone

Comments

@VladimirSlavik
Copy link

Describe the issue

Hello, I have a source string which is a plural using python format (the percent kind). In weblate, I have turned on "python format" as a mandatory check. Somebody just translated the string, and did not use the percent format. There is nothing shown on the string page indicating this is a problem, and this translation is pushed into the repository.

Detailed information below.

I already tried

  • I've read and searched the documentation.
  • I've searched for similar issues in this repository.

Steps to reproduce the behavior

  1. Go to https://translate.fedoraproject.org/translate/anaconda/rhel-9/ar/?q=%25d+_storage+device+selected&sort_by=-priority%2Cposition&checksum=
  2. Observe Flags: python-format, lack of %d in some of the translation plurals, but no related warning or error.

Expected behavior

There should be some indication that the check failed.

Screenshots

No response

Exception traceback

No response

How do you run Weblate?

Other

Weblate versions

@yurchor can you please fill in the missing parts?

Weblate deploy checks

No response

Additional context

Detailed information:

  • I am using the weblate instance at https://translate.fedoraproject.org, which runs version 4.18.2.
  • The string is in Arabic, project anaconda, component rhel-9: singular %d _storage device selected, plural %d _storage devices selected
  • Weblate correctly shows python-format in flags, and highlights the %d.
  • The Arabic translation has these:
    لا جهازَ تخزينٍ مُحدَّدٌ
    جهازُ تخزينٍ واحدٍ مُحدَّدٌ
    جهازا تخزينٍ اثنان مُحددان
    %d‏ جهاز تخزين محدد
    %d‏ جهاز تخزين محدد
    %d‏ جهاز تخزين محدد
    
  • When I run msgfmt -c, it detects correctly that this particular string's translation is wrong.
  • The same string has been a problem already in a different component, the scenario was the same.
@yurchor
Copy link
Contributor

yurchor commented Aug 3, 2023

Actually, I do not know what can be added here. It is hard to tackle with languages with many plural forms. It is allowed to skip %d for singular but I do not know how to treat this for dual and other forms in Arabic. It should be inspected by Weblate developers.

@VladimirSlavik
Copy link
Author

VladimirSlavik commented Aug 3, 2023

Sorry, I meant the details the bug template asks about deployment (versions, deploy checks). But maybe that does not matter?

@nijel
Copy link
Member

nijel commented Aug 4, 2023

Weblate allows omitting the format string when there is only a single value for the plural form. So for Arabic, it is okay to have six plurals as:

  • None storage device selected
  • One storage device selected
  • Two storage devices selected
  • %d storage devices selected
  • %d storage devices selected
  • %d storage devices selected

This is inconsistent with msgfmt -c, but allows nicer translations, and most frameworks support this behavior.

@VladimirSlavik
Copy link
Author

Thank you, that answers why this happens.

I suppose there is no way to adjust this on a component level?

Is this check done by something that I can swap with using msgfmt? I found PythonFormatCheck in https://github.com/WeblateOrg/weblate/blob/main/weblate/checks/format.py, which does not appear to be easy to isolate, so the answer there is again no?

@nijel nijel self-assigned this Aug 7, 2023
@nijel nijel added the enhancement Adding or requesting a new feature. label Aug 7, 2023
@nijel nijel changed the title Python format check not applied Python format check not applied to some plural forms Aug 7, 2023
@nijel nijel added this to the 5.0 milestone Aug 7, 2023
nijel added a commit to nijel/weblate that referenced this issue Aug 7, 2023
In some cases it might be desired to have them.

See WeblateOrg#9682
@nijel
Copy link
Member

nijel commented Aug 7, 2023

I've just implemented flag to enforce such format strings in #9695

The Weblate checks are not easy to isolate because they depend on the database. You can use enforced checks in Weblate to make sure that no broken strings are committed as translations, see https://docs.weblate.org/en/latest/admin/projects.html#enforced-checks

nijel added a commit that referenced this issue Aug 7, 2023
In some cases it might be desired to have them.

See #9682
@github-actions
Copy link

github-actions bot commented Aug 7, 2023

Thank you for your report; the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

@VladimirSlavik
Copy link
Author

Thank you! That was unexpected...

I was looking at msgfmt instead, trying to see if I could make the relaxed mode for plurals an option there. Perhaps that would be a more reasonable thing in context of the whole ecosystem - as you say, many other parts allow this, and for some format kinds it's technically sound to omit things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding or requesting a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants