Side note: as you might expect, Wikipedia's internationalization is the only system that attempts to do quantities and other formatting correctly for every goddamn language on the planet, but is considerably easier for translators to work with than the OP's examples (sorry, Sean ;)
I did some work on bringing it to JavaScript and making it HTML-aware, and since then Santhosh Thottingal has vastly extended it and it's become pervasive at Wikipedia. More projects should use it, or at least learn from it.
Ironically, this is exactly the case described in the article, and even the article got it slightly wrong. The rules in pseudocode - for this specific sentence! - are as follows:
if ((n % 10 == 1) && (n % 100 != 11)) {
// singular nominative (not accusative as article says) - 1 котенок, 101 котенок, 301 котенок
} else if (n % 10 >= 2 && n % 10 <= 4 && n % 100 <12 && n % 100 > 14) {
// singular genitive: 2 котенка, 43 котенка, 1024 котенка
} else {
// all other cases plural genitive: 5 котят, 11 котят, 212 котят
}
But this is true only for this sentence because kittens here are the subject, not the object: with Russian verb "есть" (to be, to exist) the literal translation would be "Kitten/Kittens exists/exist belonging to Harry".
Once the declension of the numbered subject(s) turns to accusative: "Гарри гладит 1 котенка" ("Harry pets one kitten"), the rules become much simpler:
I've been looking for something like this for weeks, no luck till now, I guess I should have searched for internationalization instead of localization in this specific case on google and github. This is a great starting point, thanks a bunch for sharing. Perfect for me.
I did some work on bringing it to JavaScript and making it HTML-aware, and since then Santhosh Thottingal has vastly extended it and it's become pervasive at Wikipedia. More projects should use it, or at least learn from it.
Demo: http://thottingal.in/projects/js/jquery.i18n/demo/
Github: https://github.com/wikimedia/jquery.i18n