[Bug] Unsupported locale settings
felix-seifert opened this issue · comments
I installed roadmapper
via pip and used some example code from the wiki to try out this package. However, I was blocked by the locale settings. When I try to run the script which uses roadmapper
, I get the following error.
Traceback (most recent call last):
File "/home/felixs/GitHub/declarative-planning/roadmapper/roadmap.py", line 7, in <module>
roadmap.set_timeline(TimelineMode.MONTHLY, "2023-03-15", 8, timeline_locale="en_US")
File "/home/felixs/GitHub/declarative-planning/roadmapper/env/lib/python3.10/site-packages/roadmapper/roadmap.py", line 305, in set_timeline
self.timeline.set_draw_position(self.__painter)
File "/home/felixs/GitHub/declarative-planning/roadmapper/env/lib/python3.10/site-packages/roadmapper/timeline.py", line 143, in set_draw_position
self.set_locale(self.locale_name)
File "/home/felixs/GitHub/declarative-planning/roadmapper/env/lib/python3.10/site-packages/roadmapper/timeline.py", line 108, in set_locale
self.locale_settings = TimelineLocale(locale)
File "/home/felixs/GitHub/declarative-planning/roadmapper/env/lib/python3.10/site-packages/roadmapper/timelinelocale.py", line 84, in __init__
locale.setlocale(locale.LC_ALL, locale_name)
File "/usr/lib/python3.10/locale.py", line 620, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
If I print my locale settings in Python, I get the following settings: ('en_GB', 'UTF-8')
. This equals to en_GB.utf8
on my system. roadmapper somehow requires en_US
(without utf8
). I managed to work around this issue by trying to set the locale settings in a Docker container manually to en_US
(without utf8
). I selected this setting from a very long list when I ran sudo dpkg-reconfigure locales
.
It would be very nice to decouple roadmapper
from the locale settings.
FYI: My OS is Ubuntu 22.04
and I performed the mentioned installation steps.
Edit: My Python version is 3.10.6
.
Hi, you do not have to enter 'en_US' as a locale. If you are using 'en_GB', you can create a json file containing custom timeline settings. See this code example here: https://github.com/csgoh/roadmapper/wiki/Traditional-Chinese-Roadmap-Code
The code sample shows how to change language, font and locale.
Some additional how-to guide can be found here: https://github.com/csgoh/roadmapper/wiki/How-To#how-to-change-the-timeline-display-format
As my local locale is set to en_GB.utf8
, I have to specify this exact locale in the JSON file for changing the timeline. This, indeed, works. However, I also have to specify the settings
like year
and so on. Otherwise, I will get the following error.
Traceback (most recent call last):
File "/home/felixs/GitHub/declarative-planning/roadmapper/roadmap.py", line 11, in <module>
roadmap.set_timeline(TimelineMode.MONTHLY, "2023-03-15", 8, timeline_locale="en_GB.json")
File "/home/felixs/GitHub/declarative-planning/roadmapper/env/lib/python3.10/site-packages/roadmapper/roadmap.py", line 305, in set_timeline
self.timeline.set_draw_position(self.__painter)
File "/home/felixs/GitHub/declarative-planning/roadmapper/env/lib/python3.10/site-packages/roadmapper/timeline.py", line 143, in set_draw_position
self.set_locale(self.locale_name)
File "/home/felixs/GitHub/declarative-planning/roadmapper/env/lib/python3.10/site-packages/roadmapper/timeline.py", line 112, in set_locale
) = self.locale_settings.get_timeline_locale_settings("year")
File "/home/felixs/GitHub/declarative-planning/roadmapper/env/lib/python3.10/site-packages/roadmapper/timelinelocale.py", line 100, in get_timeline_locale_settings
locale_settings = value["settings"]
KeyError: 'settings'
As an easier workaround, it would be nice to specify the locale directly to avoid repeating the boilerplate settings like year
, month
. I.e. something like roadmap.set_timeline(TimelineMode.MONTHLY, "2023-03-15", 8, timeline_locale="en_GB")
. This, however, might require a long list of many locales.
As a user, I definitely do not want to deal with these weird locale settings if I just want to create a roadmap which does not require any specific locale settings like language or special characters. Would it be possible to allow specifying locale settings without requiring them?
Think of a Danish person needing to create a roadmap for a multinational company in English...
Hi, I see your point. I will de-couple the locale from the timeline formatting in the next minor release. It should not take long.
This issue should be resolved in v1.1.1. I have removed the dependency of 'en_US'.
I tested it on my simple example and it now works like a charm.