The code is simple:
import locale
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8') # I tried de_DE and de_DE.utf8 too
locale.currency(0)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.7/locale.py", line 267, in currency
raise ValueError("Currency formatting is not possible using "
ValueError: Currency formatting is not possible using the 'C' locale.
It works when I run it on ubuntu. On alpine, however, this error pops up. I tried the workaround from this comment without success. I also added /usr/glibc-compat/bin
to PATH
on top of that script, didn't help.
Is there any way to make locales work on alpine?
Try it out yourself:
docker run --rm alpine sh -c "apk add python3; python3 -c 'import locale; locale.setlocale(locale.LC_ALL, \"de_DE.UTF-8\"); locale.currency(0)'"
Update: this repo also doesn't work.
Update: I tried this guide too, but it seems like it's not compatible with python? Even though the locale does show up, I still get this:
/app # locale -a
C
C.UTF-8
sv_SE.UTF-8
en_GB.UTF-8
ch_DE.UTF-8
pt_BR.UTF-8
ru_RU.UTF-8
it_IT.UTF-8
de_CH.UTF-8
en_US.UTF-8
fr_FR.UTF-8
nb_NO.UTF-8
de_DE.UTF-8 <--
nl_NL.UTF-8
es_ES.UTF-8
/app # python
Python 3.7.7 (default, Apr 24 2020, 22:09:29)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
'de_DE.UTF-8'
>>> locale.currency(0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/locale.py", line 267, in currency
raise ValueError("Currency formatting is not possible using "
ValueError: Currency formatting is not possible using the 'C' locale.