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?
gettext
, which you certainly ought to familiarize yourself with if you are trying to create a replacement for it. – NattyLocale::Maketext
and they seem to include a copy of the article in the distribution; search.cpan.org/~petdance/Locale-Maketext-1.12/lib/Locale/… – Natty