For some locales pluralization always takes the singular form

Hi, I’m having the following problem and I don’t understand why it’s happening:

This smart string:

{0:plural:a day|{} days} ago     // English
{0:plural:ein Tag|{} Tage} zuvor      // German
{0:plural:satu hari|{} hari} yang lalu     // Indonesian

When I pass 2 as a parameter, it should display:

2 days ago     // English
2 Tage zuvor      // German
2 hari yang lalu     // Indonesian

It works fine in English and German, but in Indonesian it always takes the singular form (“satu hari”, instead of “2 hari”), no matter what number is given.

I found the following workaround - it works fine when I specify “en” as language code like so:

{0:plural(en):satu hari|{} hari}

But I don’t understand what’s going on - is this expected? It also works if I change “en” to “de”, but it doesn’t work if I put “id”.

It’s probably worth mentioning that the working locales are defined with 2 letters - “en”, “de”, while Indonesian is “id-ID” - that’s the only difference I can see.

Does it mean that for certain locales I need to specify “en” as language code?

I’m using Unity 2021.3.10f and Localization 1.3.2.

Thanks!

Hi,

I think we only look for the language code “id” and not “id-ID”. Could you please file a bug report so we can look into this?

Sure, will do. Thanks for the quick reply!

Thanks! It actually looks like “id” is being mapped to a Singular plural rule so looks like that is the bug.
Although the rules do seem to imply that Indonesian uses a singular plural. https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_plural_rules.html#in-comp

Do you have any details on how it should work?

Unfortunately no, I don’t speak it, I just received a translation and noticed this while testing the app with it :slight_smile:

So you mean that this is intentional - there are no plural forms in Indonesian? I actually thought this may be the case, because I see several occasions in the translation where the sigular and plural forms are the same, so it makes sense.

However it still creates a kind of a “hidden and unexpected” problem in cases like these:

{0:plural:1 move|{} moves}.
{0:plural:1 langkah|{} langkah}.

So here the singular and plural forms are the same, however the developer may not know this when first creating the English string, so they may hardcode “1” like so:

{0:plural:1 move|{} moves}

instead of

{0:plural:{} move|{} moves}

And then the translator will keep that “1” and so in Indonesian it will always be hardcoded to “1”. That’s what happened in my case :slight_smile:

And here is another example:

{0:plural:a day|{} days} ago
{0:plural:satu hari|{} hari} yang lalu

In this case “hari” (day/days) is still the same in singular and plural, but since the developer put “a day”, instead of “{} day”, the translator translated it to “satu hari” (one day), and therefore the singular form gets this hardcoded “one”.

So it seems to be correct that there are no plural forms, however there are these unexpected behaviors that still cause problems and I’m not sure what would be the proper way to handle them…

In my case it looks like I can just put “plural(en)” and that seems to fix it.

Using the “en” plural will work for these use cases or you can also use a Choose formatter to give unique behavior for particular values…

I see, so that clears what’s going on :slight_smile: Thanks a lot!

1 Like