ever-co / ever-traduora

Ever® Traduora™ - Open Translation Management Platform - https://traduora.co
https://traduora.co
GNU Affero General Public License v3.0
2k stars 203 forks source link

Define a term to be translate with plurals #30

Open Ixelka opened 5 years ago

Ixelka commented 5 years ago

Is your feature request related to a problem? Please describe. It's not possible to translate with plural adaptation.

Describe the solution you'd like In the translation list it should be possible to add plural forms according to the language. i.e In french there would be 2 fields : one for 0 and 1 cases and one for > 1 cases These rules are defined for each language and are immutable.

Describe alternatives you've considered At the first time maybe it should be easier to just add plural forms whith 2 forms language.

Additional context The best example I found is the POEditor implementation : There are tabs for each form of plural existing for this language image

anthonynsimon commented 5 years ago

@BThibaut thanks for the feedback, the feature would make sense. My only concern is how should plurals look like in the exported files?

I guess depending on the format it could be:

term.one = "{} product"
term.other = "{} products"
...

Although in case someone wants to not use plurals feature, there should be an option to export the "raw" terms, such as:

term = "{} products"
...

How does this look like in the alternatives that you've found?

Ixelka commented 5 years ago

@anthonynsimon thanks for your interest on this feature.

Actually, .po files handle pluralization like that :

msgid ""
msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#: 
msgid "user.products"
msgstr[0] "You own {{ count }} product"
msgstr[1] "You own {{ count }} products"

Plural-Forms is the rule for plurals msgstr[0], msgstr[1] are the translations according to the cases in the rule in this example, it returns 1 where (n > 1)

Also, in my example {{ count }} is specific to my use case not to .po file format.

iilei commented 5 years ago

Pluralization as asked for in #40 it would be the preferred way imho

panoti commented 5 years ago

@anthonynsimon Do you accept with POEditor concept about ICU message?

anthonynsimon commented 4 years ago

I'm still evaluating the options for the pluralisation feature, but as it stands currently we will probably go for some UI components inspired by POEditor on the frontend.

On the backend side, I still gotta review what it would mean in terms of how it plays with the various import/export formats.

Any more suggestions and ideas are more than welcome of course!

chokokatana commented 3 years ago

Different export formats would require different handling. For instance, here's a chunk of xml for android:

    <string name="string1">Check it out!</string>
    <plurals name="string2">
        <item quantity="one">You\'ve got %s points</item>
        <item quantity="other">You\'ve got %s points</item>
    </plurals>

iOS has an even more specialized format requiring a separate file for plurals.