WeblateOrg / weblate

Web based localization tool with tight version control integration.
https://weblate.org/
GNU General Public License v3.0
4.62k stars 1.02k forks source link

stringsdict: Plural form zero is unsupported #6368

Closed x-sheep closed 3 years ago

x-sheep commented 3 years ago

Describe the issue

I'm trying the stringsdict support in the bleeding edge version (as implemented in https://github.com/translate/translate/pull/4398, see also #623).

The stringsdict implementation allows the category zero to be used in all languages, but Weblate does not recognize this, and only uses the categories as defined in CLDR. This leads to a mismatch between the keys being displayed and the attached values.

I already tried

To Reproduce the issue

Steps to reproduce the behavior:

  1. Create a iOS project with a stringsdict file in English.
  2. Create a translation component with the stringsdict format.
  3. Edit the string with the attached plural.
  4. Observe an incorrect number of edit fields.

Expected behavior

Three fields should be displayed:

Screenshots

Screenshot 2021-08-02 at 11 15 16

Server configuration and status

Weblate installation: Docker

 * Weblate: 4.8-1a32f00020
 * Django: 3.2.5
 * siphashc: 2.1
 * translate-toolkit: 3.3.6
 * lxml: 4.6.3
 * Pillow: 8.3.1
 * bleach: 3.3.1
 * python-dateutil: 2.8.2
 * social-auth-core: 4.1.0
 * social-auth-app-django: 4.0.0
 * django-crispy-forms: 1.12.0
 * oauthlib: 3.1.1
 * django-compressor: 2.4.1
 * djangorestframework: 3.12.4
 * django-filter: 2.4.0
 * django-appconf: 1.0.4
 * user-agents: 2.2.0
 * filelock: 3.0.12
 * setuptools: 40.8.0
 * jellyfish: 0.8.2
 * openpyxl: 3.0.7
 * celery: 5.1.2
 * kombu: 5.1.0
 * translation-finder: 2.9
 * weblate-language-data: 2021.5
 * html2text: 2020.1.16
 * pycairo: 1.16.2
 * pygobject: 3.30.4
 * diff-match-patch: 20200713
 * requests: 2.26.0
 * django-redis: 5.0.0
 * hiredis: 2.0.0
 * sentry_sdk: 1.3.1
 * Cython: 0.29.24
 * misaka: 2.1.1
 * GitPython: 3.1.18
 * borgbackup: 1.1.17
 * pyparsing: 2.4.7
 * pyahocorasick: 1.4.2
 * python-redis-lock: 3.7.0
 * Python: 3.7.3
 * Git: 2.20.1
 * psycopg2: 2.9.1
 * psycopg2-binary: 2.9.1
 * phply: 1.2.5
 * chardet: 4.0.0
 * ruamel.yaml: 0.17.10
 * tesserocr: 2.5.2
 * akismet: 1.1
 * boto3: 1.18.11
 * zeep: 4.0.0
 * aeidon: 1.9
 * iniparse: 0.5
 * mysqlclient: 2.0.3
 * Mercurial: 5.8.1
 * git-svn: 2.20.1
 * git-review: 2.1.0
 * Redis server: 6.2.3
 * PostgreSQL server: 13.3
 * Database backends: django.db.backends.postgresql
 * Cache backends: default:RedisCache, avatar:FileBasedCache
 * Email setup: django.core.mail.backends.dummy.EmailBackend: 127.0.0.1
 * OS encoding: filesystem=utf-8, default=utf-8
 * Celery: redis://cache:6379/1, redis://cache:6379/1, regular
 * Platform: Linux 5.10.25-linuxkit (x86_64)

Weblate deploy checks

WARNINGS:
?: (security.W004) You have not set a value for the SECURE_HSTS_SECONDS setting. If your entire site is served only over SSL, you may want to consider setting a value and enabling HTTP Strict Transport Security. Be sure to read the documentation first; enabling HSTS carelessly can cause serious, irreversible problems.
?: (security.W008) Your SECURE_SSL_REDIRECT setting is not set to True. Unless your site should be available over both SSL and non-SSL connections, you may want to either set this setting True or configure a load balancer or reverse-proxy server to redirect all connections to HTTPS.
?: (security.W012) SESSION_COOKIE_SECURE is not set to True. Using a secure-only session cookie makes it more difficult for network traffic sniffers to hijack user sessions.
?: (security.W018) You should not have DEBUG set to True in deployment.

INFOS:
?: (weblate.I021) Error collection is not set up, it is highly recommended for production use
        HINT: https://docs.weblate.org/en/latest/admin/install.html#collecting-errors
?: (weblate.I028) Backups are not configured, it is highly recommended for production use
        HINT: https://docs.weblate.org/en/latest/admin/backup.html
github-actions[bot] commented 3 years ago

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

x-sheep commented 3 years ago

I still only see two edit fields instead of three. While "Zero" and "Singular" are correctly labeled, the other category is still dropped.

I only ran docker compose pull to upgrade to the latest bleeding version.

nijel commented 3 years ago

You will have to recreate affected components to apply this fix (weblate loadpo --force project/component might work as well, but I'm not sure with that).

x-sheep commented 3 years ago

I already recreated the component manually. weblate loadpo --force (my component) ran successfully, but didn't fix the problem:

Screenshot 2021-08-03 at 14 53 17

nijel commented 3 years ago

Ah, there is one more thing missing. I've just fixed it in git, you can apply the fix in the database right now:

weblate shell -c 'from weblate.lang.models import Plural; from django.db.models import F; Plural.objects.filter(source=Plural.SOURCE_STRINGSDICT).update(number=F("number") + 1)'
x-sheep commented 3 years ago

After running the fix listed above, everything works 👍

nijel commented 3 years ago

Great, thanks for testing this!