[modules/datetime] Fall back to en_US.UTF-8

If no default locale is available, fall back to en_US.UTF-8.

see #159
This commit is contained in:
Tobias Witek 2018-01-21 08:55:42 +01:00
parent be20a36805
commit cb3a7b826b

View file

@ -31,7 +31,10 @@ class Module(bumblebee.engine.Module):
super(Module, self).__init__(engine, config, super(Module, self).__init__(engine, config,
bumblebee.output.Widget(full_text=self.get_time)) bumblebee.output.Widget(full_text=self.get_time))
self._fmt = self.parameter("format", default_format(self.name)) self._fmt = self.parameter("format", default_format(self.name))
lcl = self.parameter("locale", ".".join(locale.getdefaultlocale())) l = locale.getdefaultlocale()
if not l:
l = ('en_US', 'UTF-8')
lcl = self.parameter("locale", ".".join(l))
locale.setlocale(locale.LC_TIME, lcl.split(".")) locale.setlocale(locale.LC_TIME, lcl.split("."))
def get_time(self, widget): def get_time(self, widget):