Am Tue, 11 Aug 2015 09:02:33 -0700
schrieb John Benediktsson <[email protected]>:
Thank you. So I didn't overlook existing locales support.
> Properly supporting locales, even in a small way, would be a good
> thing to add.
>
> Factor is currently locale-independent, partly because of a desire for
> homoiconicity, and partly because it prevents things like tests that
> break depending on the system locale[1].
>
> We have discussed adding a locale vocabulary or a with-locale
> combinator that can influence presentation of numbers and strings,
> maybe looking at how other languages work[2]. Probably we'd want to
> keep the math.parser locale independent, but provide ways for things
> like present / printf to be locale-aware.
>
> If this is an issue for something you are building, you could use
> alien.ffi to call sprintf or use C++ stringstream or something and
> call the library from Factor, or do something slow like this, calling
> out to Python:
>
> : format-with-locale ( n locale -- s )
> swap [
> "python" , "-c" ,
> "import locale; locale.setlocale(locale.LC_ALL, \"%s\");
> print(locale.format(\"%%f\", %s))" sprintf ,
> ] { } make B utf8 [ readln ] with-process-reader ;
>
> IN: scratchpad 1.5 "fr_FR" format-with-locale .
> 1,500000
>
> ---
> [1] https://github.com/slavapestov/factor/issues/905
> [2] https://docs.python.org/3/library/locale.html
------------------------------------------------------------------------------
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk