Updated 'clock' module to change locale only if necessary.

This commit is contained in:
Lukáš Mandák 2015-01-18 11:59:05 +01:00
parent f8a7a86fab
commit efcf8c8610

View File

@ -32,13 +32,12 @@ class Clock(IntervalModule):
on_downscroll = ["scroll_format", -1] on_downscroll = ["scroll_format", -1]
def init(self): def init(self):
lang = os.environ.get('LANG', None) lang, enc = os.environ.get('LANG', None).split('.', 1)
if lang: if lang != locale.getlocale(locale.LC_TIME)[0]:
# affects function time.strftime() in whole program # affects datetime.time.strftime() in whole program
locale.setlocale(locale.LC_TIME, lang) locale.setlocale(locale.LC_TIME, (lang, enc))
if self.format is None: if self.format is None:
lang = locale.getlocale()[0]
if lang == 'en_US': if lang == 'en_US':
# MDY format - United States of America # MDY format - United States of America
self.format = ["%a %b %-d %X"] self.format = ["%a %b %-d %X"]