Browse Source

[fix] exception if locale doesn't have a date format

marc 9 years ago
parent
commit
a4c77f88d0
1 changed files with 7 additions and 1 deletions
  1. 7
    1
      searx/utils.py

+ 7
- 1
searx/utils.py View File

206
     if locale_string == 'all':
206
     if locale_string == 'all':
207
         locale_string = settings['ui']['default_locale'] or 'en_US'
207
         locale_string = settings['ui']['default_locale'] or 'en_US'
208
 
208
 
209
-    return format_date(date, locale=locale_string)
209
+    # to avoid crashing if locale is not supported by babel
210
+    try:
211
+        formatted_date = format_date(date, locale=locale_string)
212
+    except:
213
+        formatted_date = format_date(date, "YYYY-MM-dd")
214
+
215
+    return formatted_date
210
 
216
 
211
 
217
 
212
 def dict_subset(d, properties):
218
 def dict_subset(d, properties):