Updated 'clock' module to change locale only if necessary.
This commit is contained in:
parent
f8a7a86fab
commit
efcf8c8610
@ -32,13 +32,12 @@ class Clock(IntervalModule):
|
||||
on_downscroll = ["scroll_format", -1]
|
||||
|
||||
def init(self):
|
||||
lang = os.environ.get('LANG', None)
|
||||
if lang:
|
||||
# affects function time.strftime() in whole program
|
||||
locale.setlocale(locale.LC_TIME, lang)
|
||||
lang, enc = os.environ.get('LANG', None).split('.', 1)
|
||||
if lang != locale.getlocale(locale.LC_TIME)[0]:
|
||||
# affects datetime.time.strftime() in whole program
|
||||
locale.setlocale(locale.LC_TIME, (lang, enc))
|
||||
|
||||
if self.format is None:
|
||||
lang = locale.getlocale()[0]
|
||||
if lang == 'en_US':
|
||||
# MDY format - United States of America
|
||||
self.format = ["%a %b %-d %X"]
|
||||
|
Loading…
Reference in New Issue
Block a user