Osmose

I make websites and chiptunes!

  • he/him

AKAs:
Lapsed Neurotypical
JavaScript's Strongest Warrior
Fake Podcast Host
Thotleader
Vertically Integrated Boyfriend
Your Fave's Mutual
Certified 5x Severals by the RIAA
Inconsistently Medicated
The Source That Views Back
Carnally Known
The Alternative


Homepage
osmose.ceo/

lokeloski
@lokeloski
This page's posts are visible only to users who are logged in.

lizbushouse
@lizbushouse
This page's posts are visible only to users who are logged in.

Osmose
@Osmose

GNU's gettext has the ngettext function for specifying a string with plural forms in your app code:

ngettext("%d file removed", "%d files removed", n)

On the translator side, it makes you write a really complex single line of code that encodes the rules of your language in selecting which translation to use:

"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"

#, c-format
msgid "One file removed"
msgid_plural "%d files removed"
msgstr[0] "%d slika uklonjenih"
msgstr[1] "%d slika uklonjenih"
msgstr[2] "%d slika uklonjenih"

Project Fluent came out of Mozilla's localization team and volunteer community after struggling with gettext and other translation systems for years while localizing Firefox. You write a source English FTL file:

shared-photos =
    {$userName} {$photoCount ->
        [one] added a new photo
       *[other] added {$photoCount} new photos
    } to {$userGender ->
        [male] his stream
        [female] her stream
       *[other] their stream
    }.

and then translators provide an FTL file for their language with the translations filled in place of the English, with more plural forms specified as needed.

What I only learned today is that that one other stuff describing which plural forms are available are actually a standard provided in the Unicode CLDR. If you look up Polish, for example, you can see that few is used for the plural form for numbers ending in 2, 3, or 4, and many is used for the other non-fractional plurals.

(Fluent also supports arbitrary string keys, as seen with the gender selector above—"male" and "female" aren't built into Fluent, they are arbitrary keys and could be expanded to include any pronoun forms desired.)

Anyone making software that needs to be translated should be using a localization library of some sort, there's way too many edge cases and variations for you to be handling this stuff yourself!


You must log in to comment.

in reply to @lokeloski's post:

A useless fact, but English did, a long time ago, have three types of number: singular, dual, and plural—or, at least, the fossilised dual persisted in pronouns like wit ('we two'), git ('you two') and incer ('yours-but-there-are-two-of-you').

IIRC, Proto-Indo-European had dual number but a lot of the relevant grammatical architecture for nouns and verbs had already atrophied when English split off from its ancestor languages.

do you know which languages have separate 4 plurals or which ones have every number ending in "1" being singular? i knew about the trial and paucal beforehand but not these and i'd like to know more

Finnish presents an interesting corner case – it has singular and plural quite like English, but you do not use the plural number if you explicitly specify an amount

For example, let's consider a file download UI. You want to translate into Finnish the message "File Downloaded" / "Files Downloaded", which become "Tiedosto ladattu" / "Tiedostot ladattu". In both of these cases, tiedosto 'file' is in the nominative, in the former in the singular and in the latter in the plural.

If you then add a number to the UI, you can keep the one-file case as-is using nominative singular, "1 tiedosto ladattu", but the non-one-file case needs to become "5 tiedostoa ladattu", using the accusative singular