typescript-string-operations
typescript-string-operations copied to clipboard
"n" format specifier does not respect locale
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.
Hey @karelkral, thank you for your feedback! I will take care of that asap!
Maybe Intl.NumberFormat would suffice as a lightweight solution.
console.log(new Intl.NumberFormat().format(123456.789))
outputs (de)
"123.456,789"
Yes, it is a good workaround for this simple case.