Coding for the world, part 10: The one with the genders and pluralization

Today it is all about genders and pluralization. With genders we are not picking up the discussion on gendering. We are focussing on different languages and their usage of grammatical genders and pluralization. You might ask, what has this to do with me being a developer? Well, keep on reading. It does not sound like a fascinating subject, but with a closer look, it is!

Genders and their importance in code

Why do we have genders? Simply said, it is a grammatical method to categorize nouns. Most languages have two genders (feminine, masculine), such as Spanish, or three, such as German (feminine, masculine, neuter); but other languages can have even more: consider Czech (masculine animate, masculine inanimate, feminine, neuter), or that Zulu is basically sexless from a grammatical point of view (way ahead of everyone!).

Genders can make learning another language very difficult, and genders do not transfer well from one language to another. For instance, the word “sun” is masculine in Spanish but feminine in German, whereas the word “moon” is masculine in German, but feminine in Spanish. But that’s not all. With genders there are dependencies: for instance, adjectives may need to be inflected depending on the gender of the noun, or articles may change depending on the gender of what they reference.

This is the moment to focus on you, the developer, and the code. If you split parts of a unit such as an adjective and noun, it will be near to impossible for the linguist to get this right in their language. Here are some examples.

Some splits are less obvious:

"FollowRulesInLegalDocumentation": "Follow the rules as explained in our {{LegalDocumentation}}.",

Issue:

The pronoun “our” needs to be inflected depending on what it references. In this case no one knows the gender or the pluralization. Even the noun that is inserted can be affected depending on its case (nominative, genitive, or others). It matters for localization if the placeholder value is going to be “Terms and Conditions” or “Privacy Guidelines”.

Solution: write separate strings:

"FollowRulesInTOC": "Follow the rules as explained in our Terms and Conditions.",
"FollowRulesInPrivacyGuidelines": "Follow the rules as explained in our Privacy Guidelines.",

Some splits are very obvious:

"AssignTo": "Assign to",

Solution: add placeholder for names and add nouns:

"AssignToRecipient": "Assign to current recipient",
"AssignToRecipientName": "Assign to {{RecipientName}}",

There is only one thing for you to remember: Keep everything together and there will be no issues later in the process when the translations are implemented. That not only saves you from reworking the code later on, but the QA team will be very thankful, too!

Pluralization 

Singular and plural are important in English, as we indicate whether we talk about one thing in particular or many things. If you would like to ask your friend to bring three apples from the grocery store, you will most likely not say “please bring me one apple, and another apple, and one more apple” but you will say something like “can you please buy three apples for me.” With pluralization we also have verb dependencies, such as “I was in New York” and “We were in Prague”. The “was” used in singular changes to “were” in plural.

Some languages have no pluralization and others can have up to six forms. English, like German and Spanish, has two forms of pluralization, but beware: it is not as easy as you think.

Let’s take the English word “book”:

"BookSingular": "1 book",
"BookPlural": "{count} books",

The German would look like this:

"BookSingular": "1 Buch",
"BookPlural": "{count} Bücher",

If the English would have used:

"BookSingularPlural": "{count} book(s)",

The German would get cumbersome:

"BookSingularPlural": "{count} Buch/Bücher",

In English the “s” is added to indicate the plural, but in German the “u” had to be changed to umlaut “ü” and “er” was added for the plural. Appending the plural “s” in brackets works smoothly for English, but for other languages it will look very cumbersome.

Now you already know why the following is not working for localization:

"AddBook(s)ButtonLabel": "Add book(s)",

The German would be:

"AddBook(s)ButtonLabel": "Buch/Bücher hinzufügen",

This is one of the reasons why we need separate instances for singular and plural. The other reason is the dependencies of other word types, such as adjectives, articles, and, as already mentioned, verbs.

Using only singular and one plural is a mediocre solution, and you can do better. The Common Local Data Repository (CLDR) defines up to six different plural forms: zero, one, two, few, many and other.

"UserONE": "{{count}} user",
"UserZERO": "{{count}} users",
"UserTWO": "{{count}} users",
"UserFEW": "{{count}} users",
"UserMANY": "{{count}} users",
"UserOTHER": "{{count}} users",

If you would like to check out an overview of the plural rules for languages, there is an in-depth one on unicode.org.

With this, my friends, I conclude my series about localization and why you should care about it. If you just had half the fun reading my posts as I had while writing them, you made my day!

Sunny greetings from the linguist that you can trust!

Note: Thanks to Carlos Barbero-Cortés of DocuSign for consultation and feedback.

Additional resources

Bettina Becker
Author
Bettina Becker
Sr. Language Manager
Published
Related Topics