Support Locale in number?string("0.#######")
Generates text that depends on changing data (like dynamic HTML).
Brought to you by:
revusky
Hi,
It would be very handy to be able to do something like ?string("en_US","0.#######") on a number to specify the Locale to use to format the number.
My current issue is to limit the number of digits on a coordinates (lat/long) so, I want to print a dot(.) even if the Locale would use a comma (,).
Regards,
Christian
For the moment, I'm using the macro defined in this post:
https://sourceforge.net/p/freemarker/discussion/2346/thread/db5070a4
Why does the decimal separator change to "." just because it's a coordinate? Because it's program-consumed value? Then the solution would be rather
?c(4)
or like. OTOH the pattern that I want to push in future releases (far future...) is that you don't specify the mask etc., instead you indicate what the meaning of the number is, like${x?my:coord}
. And then at a central location (maybe even in Java) you specify how a coordinate should look. Anyway, that's the far future, but as far as RFE-s go, it's relevant. Or, you can do it right now with functions, like${my.coord(x)}
, it's just less appealing.Last edit: Dániel Dékány 2015-02-28
As of 2.3.24 you can specify pretty much all
DecimalFormatSymbol
-s in the pattern string, in the 3rd;
-separated section:"0.###;; dec='.'"
. It's not changing the locale, instead, you override the symbols.