typescript-string-operations icon indicating copy to clipboard operation
typescript-string-operations copied to clipboard

"n" format specifier does not respect locale

Open karelkral opened this issue 5 years ago • 3 comments

String.Format with "n" specifier does not respect current locale settings. In our country, there is a thousand separator " ". In your library is hardcoded thousand separator ".". Please use settings from the current locale.

const formatted: string = String.Format("{0:n}", 10000); returns "10.000" whould return "10 000" with cs-CZ locale.

karelkral avatar Mar 03 '20 15:03 karelkral

Hey @karelkral, thank you for your feedback! I will take care of that asap!

iwt-svenulrich avatar Mar 03 '20 16:03 iwt-svenulrich

Maybe Intl.NumberFormat would suffice as a lightweight solution.

console.log(new Intl.NumberFormat().format(123456.789))

outputs (de)

"123.456,789"

aequi42 avatar Mar 05 '20 10:03 aequi42

Yes, it is a good workaround for this simple case.

karelkral avatar Mar 05 '20 14:03 karelkral