WeblateOrg / WeblateOrg/weblate

Rails yml import: the key 'one' is loaded as plural form 'zero' if the key 'zero' is missing

Open
#4,484 7 comments 0 reactions 0 assignees View on GitHub
Blocked by upstream enhancement Waiting for: Demand
Dominant language
Python
Stars
6.1k
Forks
1.4k
Avg merge
9h 53m
Merged PRs (30d)
395

Description

**Describe the bug**

I changed the plural count and formula of French to support the 'zero' case.
- plural count: 3
- plural formula: (n == 0) ? 0 : (n == 1 ? 1 : 2)

Then, I load the following rails i18n file:

```yml
fr:
successful_key:
one: Un événement
other: '%{count} événements'
zero: Aucun événement
failing_key:
one: Un participant
other: '%{count} participant'
```

The first key `successful_key` is successfully parsed. But the second key `failing_key` like if the input was :

```yml
fr:
failing_key:
one: '%{count} participant'
other:
zero: Un participant
```

I other words, if the 'zero' key is missing, the 'one' key will be used for the plural form `n = 0`.

**To Reproduce**

* create a new project
* update the locale properties with plural count: 3 and plural formula: (n == 0) ? 0 : (n == 1 ? 1 : 2)
* use the example file below
* see the imported result

**Expected behavior**

If the zero key was missing during import, it should not corrupt other plural form.
Rails supports that the zero key is missing, so we only set it when necessary.

**Screenshots**

![Peek 10-09-2020 16-40](https://user-images.githubusercontent.com/4479304/92747601-a5bbc380-f384-11ea-8296-12f39554e0e7.gif)

**Server configuration and status**

* Weblate: 4.2.2
* Django: 3.1.1
* siphashc: 1.3
* Whoosh: 2.7.4
* translate-toolkit: 3.0.0
* lxml: 4.5.2
* Pillow: 7.2.0
* bleach: 3.1.5
* python-dateutil: 2.8.1
* social-auth-core: 3.3.3
* social-auth-app-django: 4.0.0
* django-crispy-forms: 1.9.2
* oauthlib: 3.1.0
* django-compressor: 2.4
* djangorestframework: 3.11.1
* django-filter: 2.3.0
* django-appconf: 1.0.4
* user-agents: 2.1
* filelock: 3.0.12
* setuptools: 40.8.0
* jellyfish: 0.8.2
* openpyxl: 3.0.5
* celery: 4.4.7
* kombu: 4.6.11
* translation-finder: 2.1
* html2text: 2020.1.16
* pycairo: 1.16.2
* pygobject: 3.30.4
* diff-match-patch: 20200713
* requests: 2.24.0
* django-redis: 4.12.1
* hiredis: 1.1.0
* sentry_sdk: 0.16.5
* Cython: 0.29.21
* misaka: 2.1.1
* GitPython: 3.1.7
* borgbackup: 1.1.13
* pyparsing: 2.4.7
* Python: 3.7.3
* Git: 2.20.1
* psycopg2: 2.8.5
* psycopg2-binary: 2.8.5
* phply: 1.2.5
* chardet: 3.0.4
* ruamel.yaml: 0.16.10
* tesserocr: 2.5.1
* akismet: 1.1
* boto3: 1.14.53
* zeep: 3.4.0
* aeidon: 1.7.0
* iniparse: 0.5
* mysqlclient: 2.0.1
* Mercurial: 5.5.1
* git-svn: 2.20.1
* git-review: 1.28.0
* hub: 2.13.0
* lab: 0.16
* Redis server: 4.0.14
* PostgreSQL server: 11.9
* Database backends: django.db.backends.postgresql
* Cache backends: default:RedisCache, avatar:FileBasedCache
* Email setup: django.core.mail.backends.smtp.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.3.0-1035-aws (x86_64)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.