Commits

rblank  committed 484446b

0.12.1dev: Improve handling of missing locale data, and mention that on the "About Trac" page and in semi-automatic bug reports.

Part of #9439.

  • Participants
  • Parent commits 4893f31
  • Branches 0.12-stable

Comments (0)

Files changed (2)

File trac/util/translation.py

         def activate(self, locale, env_path=None):
             try:
                 locale_dir = pkg_resources.resource_filename('trac', 'locale')
-            except pkg_resources.ExtractionError:
-                return # delay extraction
-            except KeyError:
-                return # No locale data in egg
+            except Exception:
+                return
             t = Translations.load(locale_dir, locale or 'en_US')
             if not t or t.__class__ is NullTranslations:
                 t = self._null_translations
         """Return a list of locale identifiers of the locales for which
         translations are available.
         """
-        return [dirname for dirname
-                in pkg_resources.resource_listdir('trac', 'locale')
-                if '.' not in dirname]
+        try:
+            return [dirname for dirname
+                    in pkg_resources.resource_listdir('trac', 'locale')
+                    if '.' not in dirname]
+        except Exception:
+            return []
 
     def get_negotiated_locale(preferred_locales):
         def normalize(locale_ids):

File trac/web/chrome.py

                            javascript_quote, exception_to_unicode
 from trac.util.datefmt import pretty_timedelta, format_datetime, format_date, \
                               format_time, from_utimestamp, http_date, utc
-from trac.util.translation import _
+from trac.util.translation import _, get_available_locales
 from trac.web.api import IRequestHandler, ITemplateStreamFilter, HTTPNotFound
 from trac.web.href import Href
 from trac.wiki import IWikiSyntaxProvider
         except ImportError:
             babel = None
         if babel is not None:
-            yield 'Babel', get_pkginfo(babel).get('version')
+            info = get_pkginfo(babel).get('version')
+            if not get_available_locales():
+                info += " (translations unavailable)" # No i18n on purpose
+            yield 'Babel', info
 
     # IEnvironmentSetupParticipant methods