internationalization i18n ICU4J Plurality for Scala via the MessageFormat class

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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)


Got any internationalization Question?