--- a/src/pyams_utils/size.py Fri Feb 22 12:31:08 2019 +0100
+++ b/src/pyams_utils/size.py Fri Feb 22 12:31:28 2019 +0100
@@ -12,14 +12,10 @@
__docformat__ = 'restructuredtext'
-
-# import standard library
-
-# import interfaces
-
-# import packages
+from babel import UnknownLocaleError
from babel.core import Locale
from babel.numbers import format_decimal
+
from pyams_utils.request import check_request
from pyams_utils import _
@@ -56,7 +52,10 @@
if request is None:
request = check_request()
translate = request.localizer.translate
- locale = Locale(request.locale_name)
+ try:
+ locale = Locale(request.locale_name)
+ except UnknownLocaleError:
+ locale = Locale(request.registry.settings.get('pyramid.default_locale_name', 'en'))
if value < 1024:
return format_decimal(value, translate(_('0 bytes')), locale)
value /= 1024