localize() in inkex.py ignores $LANG from current env on Windows
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Inkscape |
New
|
Undecided
|
Unassigned |
Bug Description
The localize() function in inkex.py to initialize gettext for messages returned by extension scripts seems to ignore $LANG from the current environment on Windows, and overwrites the environment variable with the locale apparently retrieved from the system settings:
import locale
Tested on Windows 10:
1) set LANG in the CMD shell before launching inkscape:
C:\Users\
C:\Users\
--> Inkscape's GUI shows with German localization as expected.
2) Launch a second Inkscape instance from within inkscape [*]:
--> GUI language and locale of second instance falls back to en_US (like the system settings).
Reproduced with Inkscape 0.91 (32bit, 64bit), 0.92.1 (32bit, 64bit) and inkscape_
Notes:
* See also the lengthy discussion in bug #1662531 about the crash of the second inkscape instance (reported separately in bug #1663697 as well) for another issue related to localize() on Windows and a proposed improvement attached in comment https:/
* Possibly locale.
1) set LANG in CMD shell to a locale different from system settings
2) launch python\python.exe as bundled with Inkscape on Windows
3) import os, locale
3) print os.environ['LANG']
4) print locale.
It seems that Python's locale module on Windows ignores LANG from the environment (unlike e.g. python on OS X, and unlike Inkscape itself).
Python documentation:
https:/
=====
[*] debug extension to spawn second Inkscape instance:
https:/
Why is it necessary to change $LANG in the environment on Windows at all? A quick test with 0.92.1 r15371 (64bit, 7z) on Windows 10 shows translated error messages from extensions even if line 57 is commented out:
# os.environ['LANG'] = current_locale
https:/ /bazaar. launchpad. net/~inkscape. dev/inkscape/ 0.92.x/ view/15371/ share/extension s/inkex. py#L57
@jazzynico - do you happen to remember why you had to add it for translations of messages from extensions scripts on Windows?