[module/datetime] Add more error handling to locale setting
If setting a locale fails with an exception, set to en_US.UTF-8 by default. fixes #159
This commit is contained in:
parent
7af04b0556
commit
20f48d4535
1 changed files with 4 additions and 1 deletions
|
@ -35,7 +35,10 @@ class Module(bumblebee.engine.Module):
|
||||||
if not l or l == (None, None):
|
if not l or l == (None, None):
|
||||||
l = ('en_US', 'UTF-8')
|
l = ('en_US', 'UTF-8')
|
||||||
lcl = self.parameter("locale", ".".join(l))
|
lcl = self.parameter("locale", ".".join(l))
|
||||||
|
try:
|
||||||
locale.setlocale(locale.LC_TIME, lcl.split("."))
|
locale.setlocale(locale.LC_TIME, lcl.split("."))
|
||||||
|
except Exception as e:
|
||||||
|
locale.setlocale(locale.LC_TIME, lcl.split("en_US.UTF-8"))
|
||||||
|
|
||||||
def get_time(self, widget):
|
def get_time(self, widget):
|
||||||
enc = locale.getpreferredencoding()
|
enc = locale.getpreferredencoding()
|
||||||
|
|
Loading…
Reference in a new issue