Embedding plural forms into translations

From Dreamwidth Notes
Jump to: navigation, search

Introduction

Different languages have different rules for selecting which form of a word to use depending on an associated item count. English says "0 images", "1 image", "2+ images". French says "0 image", "1 image", "2+ images" (that is, it treats 0 as 1, whereas English treats 0 as 2 and above.) Other languages (such as Russian) have 2 forms for the plural. Others yet (eg, Hungarian) have no distinct singular and plural and hence only one form. None of the supported languages has more than 3 forms (singular, plural1, plural2). The acceptable forms are [[?num|singular|plural1|plural2]], [[?num|singular|plural]], and [[?num|singular]], depending on the language. (The last one is probably better written as singular, but is included for completeness.) In those examples, num is the variable holding the number of items. Note that the actual number should be in the same translation string as the plural list, as some languages could conceivably place the item count after the item name, not before.

Detailed rules

English (and all languages not listed below):

[[?num|singular|plural]]
  • singular is used when num is 1.
  • plural is used in all other cases, including 0.

Russian, Ukrainian, and Belarusian:

[[?num|singular|plural1|plural2]]
  • singular is used when num is or ends in 1, except when it is or ends in 11.
  • plural1 is used when num is or ends in 2, 3, or 4, except when it is or ends in 12, 13 or 14.
  • plural2 is used in all other cases, including 0.

French and Brazilian Portuguese:

[[?num|singular|plural]]
  • singular is used when num is 0 or 1.
  • plural is used in all other cases, that is when num is 2 or more.

Lithuanian:

[[?num|singular|plural1|plural2]]
  • singular is used when num is or ends in 1, except when it is or ends in 11.
  • plural1 is used in all cases besides those described in singular or plural2.
  • plural2 is used when num is 0 or within range 10-19; the last two digits of num are in range 10-19; or num is a multiple of 10.

Polish:

[[?num|singular|plural1|plural2]]
  • singular is used when num is 1.
  • plural1 is used when num is or ends in 2, 3, or 4, except when it is or ends in 12, 13 or 14.
  • plural2 is used in all other cases, including 0.

Hungarian, Japanese, and Turkish:

[[?num|singular]]
  • singular is always used. (as noted above, this is silly, but LiveJournal lets you do it, so...)

Latvian:

[[?num|singular|plural|nullar]]
  • singular is used when num is or ends in 1, except when it is or ends in 11.
  • plural is used in all cases besides those described in singular or nullar.
  • nullar is used when num is 0.

Icelandic:

[[?num|singular|plural]]
  • singular is used when num is or ends in 1, except when it is or ends in 11.
  • plural is used in all other cases, including 0.

A practical example

A page discussing calendars may mention the number of days in a given month. That reference, in the untranslated English version, may look like [[monthdays]] [[?monthdays|day|days]]. In this hypothetical example, [[monthdays]] would be replaced by the actual number of days in the month before the page is sent to the user, and you should copy it verbatim to your translation. In addition, you should replace [[?monthdays|day|days]] with the appropriate rule for your language; that rule would typically include appropriate translations for "day" and "days" (including any additional forms your language may use). Thus, the French translation would be [[monthdays]] [[?monthdays|jour|jours]]. Also, if your language wants the count in another position than just before the item name, you should move [[monthdays]] to its proper position in the translated text.

Tricks, special cases, and historical oddities

Some translation strings introduced before the plural feature existed have two versions, one for the singular and one for the plural. An example is:

Code: /userinfo.bml.timeupdate.dayago
English (LJ): 1 day ago
Code: /userinfo.bml.timeupdate.daysago
English (LJ): [[num]] days ago

which would normally be written as

Code: /userinfo.bml.timeupdate.daysago
English (LJ): [[num]] [[?num|day|days]] ago

(with a single string for both singular and plural.) The [[?...]] sequence can be used in translations even if the original English text doesn't use it, as long as the English uses [[num]]. Thus, for those languages with pluralization rules that don't match English, you could have (in French) il y a [[num]] [[?num|jour|jours]] for the plural strings (or suitable equivalents for other languages), even though that string in English doesn't use [[?...]] and only uses [[num]]. However, it couldn't be used for the singular, which uses neither [[?...]] nor [[num]].

Credits

Draft translation from the Perl code by [info]pauamma. Corrections and rewording for clarity by [info]camomiletea and [info]janinedog. Tricks section based on a suggestion by [info]parasti in [info]lj_latvian.