ICU4J 通過 MessageFormat 類實現 Scala 的多元化

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)