-
Notifications
You must be signed in to change notification settings - Fork 9
How to manage plural in translation
dauphine-dev edited this page Dec 5, 2018
·
4 revisions
- In English we have that
"dtMany": { "message": "s" },
"dtSingle": { "message": "" },
"dtYears": { "message": "$years$ year$plural$", "placeholders": { "years": { "content": "$1" }, "plural": { "content": "$2" } } },
"dtMonths": { "message": "$months$ month$plural$", "placeholders": { "months": { "content": "$1" }, "plural": { "content": "$2" } } },
"dtDays": { "message": "$days$ day$plural$", "placeholders": { "days": { "content": "$1" }, "plural": { "content": "$2" } } },
"dtHours": { "message": "$hours$ hour$plural$", "placeholders": { "hours": { "content": "$1" }, "plural": { "content": "$2" } } },
"dtMinutes": { "message": "$minutes$ minute$plural$", "placeholders": { "minutes": { "content": "$1" }, "plural": { "content": "$2" } } },
"dtSeconds": { "message": "$seconds$ second$plural$", "placeholders": { "seconds": { "content": "$1" }, "plural": { "content": "$2" } } }
Entry "dtMany" is for the plural mark.
Entry "dtSingle" is for the singular mark.
- For example to translate year/years to French an/ans (nothing for singular, 's' for plural) process like that:
"dtMany": { "message": "s" },
"dtSingle": { "message": "" },
"dtYears": { "message": "$years$ an$plural$", "placeholders": { "years": { "content": "$1" }, "plural": { "content": "$2" } } },
you will get for example "1 an", "5 ans".
- For example to translate year/years to Italian anno/anni (nothing for singular, 's' for plural) process like that:
"dtMany": { "message": "i" },
"dtSingle": { "message": "o" },
"dtYears": { "message": "$years$ ann$plural$", "placeholders": { "years": { "content": "$1" }, "plural": { "content": "$2" } } },
you will get for example "1 anno", "5 anni".
- If one word works differently like month in Italian mese/mesi then process like that (don't use the generic plural management and use parentheses) :
"dtMany": { "message": "i" },
"dtSingle": { "message": "o" },
"dtMonths": { "message": "$months$ mese(i)", "placeholders": { "months": { "content": "$1" }, "plural": { "content": "$2" } } },
you will get for example "1 mese(i)", "5 mese(i)".
- If your language don't use suffix but prefix (or some thing in the middle) then process like that
-prefix:
"dtMany": { "message": "pluralMark" },
"dtSingle": { "message": "singularMark" },
"dtYears": { "message": "$years$ $plural$yearWord", "placeholders": { "years": { "content": "$1" },
-in the middle:
"dtMany": { "message": "pluralMark" },
"dtSingle": { "message": "singularMark" },
"dtYears": { "message": "$years$ yearWordPart1$plural$yearWordPart2", "placeholders": { "years": { "content": "$1" },
-and so on...
- I can see many times the word to translate, should I translate all occurrences ?
-> No I have to translate only the #### part (see the example below).
In the example below, the part #### will become the word for year in the target language, other stuffs have to keep untouched.
"dtYears": {
"message": "$years$ ####$plural$",
"placeholders": {
"years": {
"content": "$1"
},
"plural": {
"content": "$2"
}
}
},