Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Unsupported locale settings #15

Closed
felix-seifert opened this issue Mar 24, 2023 · 6 comments
Closed

[Bug] Unsupported locale settings #15

felix-seifert opened this issue Mar 24, 2023 · 6 comments

Comments

@felix-seifert
Copy link
Collaborator

felix-seifert commented Mar 24, 2023

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.

@csgoh
Copy link
Owner

csgoh commented Mar 25, 2023

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.

@csgoh
Copy link
Owner

csgoh commented Mar 25, 2023

Some additional how-to guide can be found here: https://github.com/csgoh/roadmapper/wiki/How-To#how-to-change-the-timeline-display-format

@felix-seifert
Copy link
Collaborator Author

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...

@csgoh
Copy link
Owner

csgoh commented Mar 29, 2023

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.

@csgoh
Copy link
Owner

csgoh commented Apr 1, 2023

This issue should be resolved in v1.1.1. I have removed the dependency of 'en_US'.

@csgoh csgoh closed this as completed Apr 1, 2023
@felix-seifert
Copy link
Collaborator Author

I tested it on my simple example and it now works like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants