# HG changeset patch
# User Christian Boos <cboos@neuf.fr>
# Date 1285878280 -7200
# Branch 0.12-stable
# Node ID 9ae5065f71cf88e63e27388d38b05c1b80e874f0
# Parent 4893f31835196bb97bab595b2dffc4d67eebea8d
0.12.1dev: add an explicit warning in the log and in the About page when Babel was installed after Trac and no catalogs are available.
Related to #9439.
diff -r 4893f3183519 trac/util/translation.py
|
a
|
b
|
try: |
| 341 | 341 | |
| 342 | 342 | has_babel = True |
| 343 | 343 | |
| | 344 | try: |
| | 345 | locales = pkg_resources.resource_listdir('trac', 'locale') |
| | 346 | # TODO: (optimization) early extraction of all locales |
| | 347 | except pkg_resources.ExtractionError: |
| | 348 | pass # delay extraction |
| | 349 | except Exception: |
| | 350 | has_babel = False # No locale data in egg |
| | 351 | |
| 344 | 352 | except ImportError: # fall back on 0.11 behavior, i18n functions are no-ops |
| | 353 | has_babel = None |
| | 354 | |
| | 355 | if not has_babel: |
| 345 | 356 | gettext = _ = gettext_noop |
| 346 | 357 | dgettext = dgettext_noop |
| 347 | 358 | ngettext = ngettext_noop |
diff -r 4893f3183519 trac/web/chrome.py
|
a
|
b
|
from trac.util.text import pretty_size, |
| 47 | 47 | javascript_quote, exception_to_unicode |
| 48 | 48 | from trac.util.datefmt import pretty_timedelta, format_datetime, format_date, \ |
| 49 | 49 | format_time, from_utimestamp, http_date, utc |
| 50 | | from trac.util.translation import _ |
| | 50 | from trac.util.translation import _, has_babel |
| 51 | 51 | from trac.web.api import IRequestHandler, ITemplateStreamFilter, HTTPNotFound |
| 52 | 52 | from trac.web.href import Href |
| 53 | 53 | from trac.wiki import IWikiSyntaxProvider |
| … |
… |
class Chrome(Component): |
| 374 | 374 | def get_system_info(self): |
| 375 | 375 | import genshi |
| 376 | 376 | yield 'Genshi', get_pkginfo(genshi).get('version') |
| 377 | | try: |
| | 377 | if has_babel is not None: |
| 378 | 378 | import babel |
| 379 | | except ImportError: |
| 380 | | babel = None |
| 381 | | if babel is not None: |
| 382 | | yield 'Babel', get_pkginfo(babel).get('version') |
| | 379 | babel_info = get_pkginfo(babel).get('version') |
| | 380 | if has_babel is False: |
| | 381 | babel_info += " (Babel was installed after Trac, " \ |
| | 382 | "no translations are available)" # Note: no i18n on purpose |
| | 383 | self.log.warning("Babel: version %s", babel_info) |
| | 384 | yield 'Babel', babel_info |
| 383 | 385 | |
| 384 | 386 | # IEnvironmentSetupParticipant methods |
| 385 | 387 | |