Search Unity

Question How to handle smart strings with multiple variants?

Discussion in 'Localization Tools' started by eblavender, Apr 28, 2021.

  1. eblavender

    eblavender

    Joined:
    Sep 4, 2017
    Posts:
    14
    Hi there!

    I have seen that it is possible to handle singular and plural integers when using smart strings to produce different words, however for some languages it extends beyond this.

    For example for Polish, if its 1 its gonna be ‘ściane’ if 2/3 and 4 – ściany, 5 & more – ścian 21/22/23/24 (repeat on 30’s and the rest) – ściany.

    What is the best way to handle this? Any help is greatly appreciated!
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,300
    The plural system handles this.

    We follow the Unicode cardinal approach:
    https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html

    You can see Polish has 4 types, one, few, many and other
    So your Smart String would look like:
    https://docs.unity3d.com/Packages/com.unity.localization@0.11/manual/Pluralization.html

    Code (csharp):
    1. "There are {0:plural:one | few | many | other}."
    So I think you would do
    Code (csharp):
    1. "{0:plural:{} ‘ściane’|{} ściany|{} ścian|{} ściany}
     
    Last edited: Apr 28, 2021
    eblavender likes this.
  3. eblavender

    eblavender

    Joined:
    Sep 4, 2017
    Posts:
    14
    Ok I will try this thanks very much! :)
     
    karl_jones likes this.