scala-java-locales icon indicating copy to clipboard operation
scala-java-locales copied to clipboard

DO NOT MERGE: Support non-latin formats

Open er1c opened this issue 9 years ago • 5 comments

For some reason this breaks on the JVM, even though its not reproducible on the console:

eric@Erics-MacBook-Pro:~/Work/scala-java-locales$ sbt console
[info] Loading project definition from /Users/eric/Work/scala-java-locales/project
[info] Set current project to scala-java-locales (in build file:/Users/eric/Work/scala-java-locales/)
[info] Starting scala interpreter...
[info]
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_111).
Type in expressions for evaluation. Or try :help.

scala> import java.util.Locale
import java.util.Locale

scala> import java.text.NumberFormat
import java.text.NumberFormat

scala> val locale = Locale.forLanguageTag("hi-IN")
locale: java.util.Locale = hi_IN

scala> val decimalFormat = NumberFormat.getInstance(locale)
decimalFormat: java.text.NumberFormat = java.text.DecimalFormat@674dc

scala> decimalFormat.format(1234567890.123)
res0: String = १,२३४,५६७,८९०.१२३

er1c avatar Dec 18 '16 23:12 er1c

@er1c this is reproducible with export JAVA_OPTS="-Djava.locale.providers=CLDR"

er1c avatar Dec 18 '16 23:12 er1c

@er1c you can use java.util.Locale.getAvailableLocales.foreach { l => println(s"${l} - ${java.text.NumberFormat.getInstance(l).format(123456789.01)}") } to get a list if you have that export up

er1c avatar Dec 18 '16 23:12 er1c

@er1c I tested this locally and I reproduce that it works on JVM but not on JS, any plans about getting this to work?

cquiroz avatar Dec 28 '16 18:12 cquiroz

@cquiroz there is a reason it says do not merge :) we need to fix the getZeroDigit to pull from the CLDR, then I think this should work

er1c avatar Dec 28 '16 20:12 er1c

Ok, no pressure, just checking in 😄

cquiroz avatar Dec 28 '16 21:12 cquiroz