mirror of
https://github.com/slgobinath/SafeEyes.git
synced 2025-01-07 01:31:26 +01:00
Fix UnknownLocaleError thrown from babel
This commit is contained in:
parent
0953abe855
commit
33f744f21c
@ -35,6 +35,7 @@ import threading
|
|||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
from logging.handlers import RotatingFileHandler
|
from logging.handlers import RotatingFileHandler
|
||||||
|
|
||||||
|
import babel.core
|
||||||
import babel.dates
|
import babel.dates
|
||||||
import gi
|
import gi
|
||||||
gi.require_version('Gtk', '3.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
@ -119,7 +120,12 @@ def format_time(time):
|
|||||||
Format time based on the system time.
|
Format time based on the system time.
|
||||||
"""
|
"""
|
||||||
sys_locale = system_locale(locale.LC_TIME)
|
sys_locale = system_locale(locale.LC_TIME)
|
||||||
|
try:
|
||||||
return babel.dates.format_time(time, format='short', locale=sys_locale)
|
return babel.dates.format_time(time, format='short', locale=sys_locale)
|
||||||
|
except babel.core.UnknownLocaleError:
|
||||||
|
# Some locale types are not supported by the babel library.
|
||||||
|
# Use 'en' locale format if the system locale is not supported.
|
||||||
|
return babel.dates.format_time(time, format='short', locale='en')
|
||||||
|
|
||||||
|
|
||||||
def mkdir(path):
|
def mkdir(path):
|
||||||
|
Loading…
Reference in New Issue
Block a user