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.

Hello Nina,
But there is still a challenge in Arabic when translating in such method, for example when i translate django and django related packages, i face an issue that I can’t drop %1d for example from the translated form of ‘2’ for ‘two’ for example, because in Arabic we don’t use the number 2 when saying 2 items, we have a special word for two when describing items such as ‘2 hours’ or ‘2 weeks’ or ‘2 servers’ etc… which is not allowing me to save unless i actually write ‘2 the-two-word-here’ which is funny and not accurate.

is that related to django or how transifex works?

btw that’s not the only case, even with number 1 we don’t say 1 hour we say an hour or a week or “one week” as two words for “1 week”


Bashar Al-Abdulhadi
https://www.transifex.com/user/profile/KuwaitNET/

Hello @Bashar thank you for the additional clarifications. If I understood correctly, some Arabic plural forms do not need to render a variable at all. If this is true then:

  1. Dropping a variable from a plural form in Transifex will result in a translation check (QA check) warning or error, that a variable is missing thus not saving the translation. To overcome this issue in Transifex, you will need to speak with the administrator of the project you are translating into setting the translation check as warning.

  2. Even if the above translations are allowed in Transifex editor, there might be problems when the translations reach the actual application. The compiler might through an error if a variable is missing in a specific plural form. I’m not 100% sure for these cases as it depends on the specific frameworks used, e.g. Django, Ruby, node.js

A possible improvement on Transifex side would be to have a set of languages that it will allow dropping of variables from some plural forms, so that no changes on the translation checks are needed from the administrators. If you are aware of any other languages that have similar linguistic behaviour like the Arabic please share here.

1 Like