Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localization of singular/plural words - what are the different language rules for grammatical numbers?

I have been developing a .NET string formatting library to assist with localization of an application. It's called SmartFormat and is open-source on GitHub.

One of the issues it tries to address is Grammatical Numbers. This is also known as "singular and plural forms" or "conditional formatting", and here's a snippet of what it looks like in English:

var message = "There {0:is|are} {0} {0:item|items} remaining";

// You can use the Smart.Format method just like using String.Format:
var output = Smart.Format(CultureInfo.CurrentUICulture, message, items.Count);

The English rule, as I'm sure you know, is that there are 2 forms (singular and plural) that can apply to nouns, verbs, and adjectives. If the quantity is 1 then singular is used, otherwise the plural is used.

I am now trying to "broaden my horizons" by implementing the correct rules for other languages! I have come to understand that some languages can have up to 4 plural forms, and it takes some logic to determine the correct form. I would like to expand my code to accomodate multiple languages. For example, I've heard that Russian, Polish, and Turkish, have pretty different rules than English, so that might be a great starting point.

However, I only speak English and Spanish, so how can I determine the correct grammatical rules for many common languages?

Edit: I also would like to know some good non-English "test phrases" for my unit tests here: What are some good non-English phrases with singular and plural forms that can be used to test an internationalization and localization library?

like image 347
Scott Rippey Avatar asked Aug 21 '11 05:08

Scott Rippey


1 Answers

Definitely, different languages have different pluralization rules. Especially interesting could be Arabic and Polish both of which contain quite a few plural forms.

If you want to learn more about these rules, please visit Unicode Common Locale Data Repository, namely Language Plural Rules.

There are quite a few interesting information there, unfortunately some of them are unfortunately wrong. I hope plural forms are correct (at least for Polish they are, as far as I could tell :) ).

like image 104
Paweł Dyda Avatar answered Oct 15 '22 19:10

Paweł Dyda