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

Native PO and MO pluralization #29963

Closed
Stadly opened this issue Jan 23, 2019 · 4 comments
Closed

Native PO and MO pluralization #29963

Stadly opened this issue Jan 23, 2019 · 4 comments

Comments

@Stadly
Copy link
Contributor

Stadly commented Jan 23, 2019

The PO translation file format and MO translation file format natively support pluralization, making it easy to translate pluralizable strings using tools such as Poedit.

The PoFileLoader and MoFileLoader support the native pluralization.

The PoFileDumper and MoFileDumper, however, do not support the native pluralization. It would be really nice if this could be implemented.

The PO format is:

msgid untranslated-string-singular
msgid_plural untranslated-string-plural
msgstr[0] translated-string-case-0
...
msgstr[N] translated-string-case-n

For example:

msgid "found %d fatal error"
msgid_plural "found %d fatal errors"
msgstr[0] "s'ha trobat %d error fatal"
msgstr[1] "s'han trobat %d errors fatals"

This works very well when the untranslated language only has two pluralization forms (singular and plural). The translated language can have more complex rules. I don't think the native pluralization can be used when the untranslated language has complex pluralization rules, or when using Explicit Interval Pluralization.

Note: It seems that the Qt format also support pluralization natively (numerusform). The QtFileDumper does not support this, and it doesn't seem that QtFileLoader does either.

@nicolas-grekas
Copy link
Member

Would you like to send a PR to achieve so? That'd be welcome and the best way to make it happen if you need it.

@deguif
Copy link
Contributor

deguif commented Apr 6, 2019

I had a look at this issue for #eufossa
It's not possible to dump plural form for PO/MO file as plural form can't be determined from the translations catalogue, (plural and singular in PO/MO are different keys) that's why it's not implemented.

@nicolas-grekas
Copy link
Member

Makes sense, please submit a PR if you think otherwise ;) I'm closing for now.

@Stadly
Copy link
Contributor Author

Stadly commented Apr 26, 2019

I've now submitted a PR :) #31269

fabpot added a commit that referenced this issue Jul 8, 2019
…tadly)

This PR was submitted for the master branch but it was squashed and merged into the 4.4 branch instead (closes #31269).

Discussion
----------

[Translator] Dump native plural formats to po files

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29963, #10152
| License       | MIT
| Doc PR        |

Implementing support for dumping to the native po plural format.

```
'foo|foos' => 'bar|bars'
```

Before, the entry above was dumped directly:
```
msgid "foo|foos"
msgstr "bar|bars"
```

With this PR, it is dumped using the native po plural format:
```
msgid "foo"
msgid_plural "foos"
msgstr[0] "bar"
msgstr[1] "bars"
```

Strings using explicit rules or contain more than 2 pluralization forms are still dumped directly, as the po format does not support such cases:

```
'{0} no foos|one foo|%count% foos' => '{0} no bars|one bar|%count% bars'
```

```
msgid "{0} no foos|one foo|%count% foos"
msgstr "{0} no bars|one bar|%count% bars"
```

This PR complements #31266, fixing loading of native po plural formats.

Commits
-------

dc31739 [Translator] Dump native plural formats to po files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants