Where does the "5" come from in the json-export of pluralized strings?

Hello everyone,

When I GET /project/<project_slug>/resource/<resource_slug>/translation/<lang_code>/, I receive the JSON data that I expect.

I am puzzled by one detail, however. In the following example, the source string is pluralized. What I don’t understand is the meaning of the keys in the dictionary.

    {
        "comment": "\n",
        "context": "",
        "key": "You have {num} attempt left.:You have {num} attempts left.",
        "string_hash": "0d4813690c5a3f4a4e1b68669285f5be",
        "reviewed": false,
        "pluralized": true,
        "source_string": {
            "1": "You have {num} attempt left.",
            "5": "You have {num} attempts left."
        },
        "translation": {
            "1": "Il vous reste {num} chance.",
            "5": "Il vous reste {num} chances."
        }
    },
  • Why “1” and “5”? What do these numbers mean?
  • Can I rely on my English-plurals to always be stored under “5”?
  • I suspect that if my source language had been Russian I would have had other numbers there. Is that correct?
  • Where can I find some documentation about this?

Hi @Bertrand_Delforge,

Thank you for submitting your questions.

Please find my comments/answers below:

  • Why “1” and “5”? What do these numbers mean?
    Answer:
    1 refers to the form “one” and “5” refers to the form “other”

  • Can I rely on my English-plurals to always be stored under “5”?
    Answer:
    I am not sure I have understood your question. Could you elaborate a little bit on this?

  • I suspect that if my source language had been Russian I would have had other numbers there. Is that correct?
    Answer:
    Correct! Each language has its own plural rules specified here

  • Where can I find some documentation about this?
    Answer:
    Except for the link provided above, you can also check our documentation guide here and here

I hope this helps.

Please let me know if you need any additional clarification.

Regards,
Nina

1 Like

Thank you for the link to the Language Plural Rules, that’s going to be useful.

So, do the numbers 1 to 5 in the json-serialized data map to [One, Two, Few, Many, Other] in that order?

Hi @Bertrand_Delforge,

Please note that the number of forms depends on the language. Each language has its own rules so for example, if you are referring to English then only 2 forms will be defined:

  • ‘1’ for ‘one’
  • ‘5’ for ‘other’

If you are referring to Arabic, though, we need to have the following forms instead:

  • ‘0’ for ‘zero’
  • ‘1’ for ‘one’
  • ‘2’ for ‘two’
  • ‘3’ for ‘few’
  • ‘4’ for ‘many’
  • ‘5’ for ‘other’
1 Like

Perfect; that’s exactly what I needed. Thank you very much.