internationalization i18n ICU4J Plurality for Scala via the MessageFormat class


Example

import com.ibm.icu.text.MessageFormat
import java.util.Locale
import scala.collection.JavaConverters._
 

// Outputs "A common message for all options. Selected: (other)"
val formatted = new MessageFormat(
  "{messageCount, plural, one {{aMessage} (one)} other {{aMessage} (other)} }",
  new java.util.Locale("en_US")
).format(Map(
  "messageCount" -> 900,
  "aMessage" -> "A common message for all options. Selected: "
).asJava)