Commits

Christian Boos  committed 445a3d0

1.0.2dev: follow-up to r11684, `parse_date()` needs the full list of locales

  • Participants
  • Parent commits 4885a04
  • Branches 1.0-stable

Comments (0)

Files changed (2)

File trac/util/datefmt.py

         'period_names': period_names,
     }
 
-_I18N_PARSE_DATE_PATTERNS = dict(map(lambda l: (l, False),
-                                     get_available_locales()))
+_I18N_PARSE_DATE_PATTERNS = dict(
+    (l, False) for l in get_available_locales(check_catalog=False))
 
 def _i18n_parse_date(text, tzinfo, locale):
     locale = Locale.parse(locale)

File trac/util/translation.py

     def get_translations():
         return translations
 
-    def get_available_locales():
+    def get_available_locales(check_catalog=True):
         """Return a list of locale identifiers of the locales for which
         translations are available.
+
+        :param check_catalog: if `True` check for the compiled catalog
+                              (.mo), otherwise the presence of the
+                              directory is enough.
         """
         try:
             return [dirname for dirname
                     in pkg_resources.resource_listdir('trac', 'locale')
                     if '.' not in dirname
-                    and pkg_resources.resource_exists(
-                    'trac', 'locale/%s/LC_MESSAGES/messages.mo' % dirname)]
+                    and (not check_catalog or pkg_resources.resource_exists(
+                        'trac', 'locale/%s/LC_MESSAGES/messages.mo' % dirname))]
         except Exception:
             return []
 
     def get_translations():
         return translations
 
-    def get_available_locales():
+    def get_available_locales(check_catalog=True):
         return []
 
     def get_negotiated_locale(preferred=None, default=None):