Base interface language on LC_MESSAGES (#231)

Instead of LC_TIME base interface on LC_MESSAGES.  In addition make use
of new optional arg to system_locale() in format_time() to have time
formatting based on LC_TIME.
This commit is contained in:
aostruszka 2018-01-17 00:44:40 +01:00 committed by Gobinath
parent 65d88ffce4
commit 992b091cf7
1 changed files with 3 additions and 3 deletions

View File

@ -91,13 +91,13 @@ def execute_main_thread(target_function, args=None):
GLib.idle_add(target_function)
def system_locale():
def system_locale(category=locale.LC_MESSAGES):
"""
Return the system locale. If not available, return en_US.UTF-8.
"""
try:
locale.setlocale(locale.LC_ALL, '')
sys_locale = locale.getlocale(locale.LC_TIME)[0]
sys_locale = locale.getlocale(category)[0]
if not sys_locale:
sys_locale = 'en_US.UTF-8'
return sys_locale
@ -110,7 +110,7 @@ def format_time(time):
"""
Format time based on the system time.
"""
sys_locale = system_locale()
sys_locale = system_locale(locale.LC_TIME)
return babel.dates.format_time(time, format='short', locale=sys_locale)