Previous tutorials have covered setting up basic item pluralization, and localization practices in general. In this tutorial we will cover setting up pluralization rules for languages with more complex rules like Polish and Russian, and how to find out the rules for any language.
You will need this information when you send your centralized localization file to localizers.
The Basics in English
We can use FText::Format
to output "day" or "days" depending on the value of
NumDays
. In English we use a singlar form when there is 1 of something (day),
and plural in all other situations (0 day, 2 days, 123 days).
Simple Plural Example in English
Will output 1 day, 2 days etc. depending on the value of NumDays
{NumDays} {NumDays}|plural(one=day,other=days)
Languages Other than English
Not all languages follow the same rules as English.
The Unicode Langauge Plural Rules document describes how each language changes words according to pluralization rules.
English Plural Rules
Name | Category | Examples | Minimal Pairs |
---|---|---|---|
English | one | 1 | 1 day |
other | 0, 2~16, 100, 1000, 10000, 100000, 1000000, … | 2 days | |
0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … | 1.5 days |
FText::Format
uses the same keywords shown in the Category column to allow
localizers to specify what word should be used for different values of the number.
Let's go through an example with more complex plural rules that English.
Polish Example
We will use Polish as an example. In Polish, there are different forms of the word for when there number is 1, for when the number ends in 2~4 (with 12~14 excluded), and for 0 and 5~19. This is explained in the Polish section of the Unicode document
Polish Plural Rules
'Minimal Pairs' column contains Polish examples for 1 month, 2 months etc.
Name | Category | Examples | Minimal Pairs |
---|---|---|---|
Polish | one | 1 | 1 miesiąc |
few | 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … | 2 miesiące | |
many | 0, 5~19, 100, 1000, 10000, 100000, 1000000, … | 5 miesięcy | |
other | 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … | 1,5 miesiąca |
We can use this information, in particular the Category column to create a Polish translation, with correct plural rules to be used by FText::Format
.
Polish translation using correct plural forms
{NumMonths} {NumMonths}|plural(one=miesiąc,few=miesiące,many=miesięcy,other=miesiąca)
I didn't find much documentation for this feature online, so hopefully this will help you in localizing your game into other languages!
As always if you have any comments or questions, you can contact me on Twitter @_benui