Usage will be:
load locale.so
# Initialize all LC_* settings from the environment.
# Note that the LC_NUMERIC locale is saved internally, and reset to 'C'.
locale all set {}
# [locale values] returns some information if you want to use
# it directly in your program.
# Note that either: locale all set {} must be called,
# or 'numeric' and 'monetary' locale settings must be set.
# and as outlined below, 'numeric' must be reverted back to 'C'.
# This can be expanded to return more information if wanted.
locale values
-> decimal_point , thousands_sep . grouping 33 currency_symbol €
# Getting LC_NUMERIC will return the correct value, though
# in reality, it is still set to 'C'.
locale numeric get
-> de_DE.UTF-8
# the format statement is locale aware
# setting LC_NUMERIC explicitly works, but you have to remember to
# change it back
locale numeric set de_DE.UTF-8
set x [format %.1f 1.5]
-> 1,5
locale numeric set C
# scan is not locale aware (<unhappy>)
# this regsub handles 90+% of the different locales, I expect
regsub , $x . x
scan $x %f myvalue
# On windows LC_MESSAGES returns the LC_ALL setting
locale messages get
-> de_DE.UTF-8
# Windows: setting LC_MESSAGES saves the value, but doesn't change any
# locale settings.
locale messages set en_US.UTF-8
locale messages get
-> en_US.UTF-8
I already have a collate function written for use with lsort.
https://sourceforge.net/p/tcl-collate/code/ci/default/tree/
(The setlocale.c code there *only* sets LC_COLLATE).
I also have a localized, (and should be scalable) spinbox written.
The localized spinbox needs more testing, but everything seems to be ok.
The new locale.c needs testing on windows.