Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 482034 | Differences between
and this patch

Collapse All | Expand All

(-)trac/util/datefmt.py (-3 / +6 lines)
Lines 36-47 Link Here
36
        get_time_format, get_month_names,
36
        get_time_format, get_month_names,
37
        get_period_names, get_day_names
37
        get_period_names, get_day_names
38
    )
38
    )
39
    from babel.localedata import list as get_known_locales
40
39
except ImportError:
41
except ImportError:
40
    babel = None
42
    babel = None
43
    def get_known_locales():
44
        return []
41
45
42
from trac.core import TracError
46
from trac.core import TracError
43
from trac.util.text import to_unicode, getpreferredencoding
47
from trac.util.text import to_unicode, getpreferredencoding
44
from trac.util.translation import _, ngettext, get_available_locales
48
from trac.util.translation import _, ngettext
45
49
46
# Date/time utilities
50
# Date/time utilities
47
51
Lines 534-541 Link Here
534
        'period_names': period_names,
538
        'period_names': period_names,
535
    }
539
    }
536
540
537
_I18N_PARSE_DATE_PATTERNS = dict(
541
_I18N_PARSE_DATE_PATTERNS = dict((l, False) for l in get_known_locales())
538
    (l, False) for l in get_available_locales(check_catalog=False))
539
542
540
def _i18n_parse_date(text, tzinfo, locale):
543
def _i18n_parse_date(text, tzinfo, locale):
541
    locale = Locale.parse(locale)
544
    locale = Locale.parse(locale)
(-)trac/util/translation.py (-8 / +3 lines)
Lines 330-349 Link Here
330
    def get_translations():
330
    def get_translations():
331
        return translations
331
        return translations
332
332
333
    def get_available_locales(check_catalog=True):
333
    def get_available_locales():
334
        """Return a list of locale identifiers of the locales for which
334
        """Return a list of locale identifiers of the locales for which
335
        translations are available.
335
        translations are available.
336
337
        :param check_catalog: if `True` check for the compiled catalog
338
                              (.mo), otherwise the presence of the
339
                              directory is enough.
340
        """
336
        """
341
        try:
337
        try:
342
            locales = [dirname for dirname
338
            locales = [dirname for dirname
343
                       in pkg_resources.resource_listdir('trac', 'locale')
339
                       in pkg_resources.resource_listdir('trac', 'locale')
344
                       if '.' not in dirname
340
                       if '.' not in dirname
345
                       and (not check_catalog or pkg_resources.resource_exists(
341
                       and pkg_resources.resource_exists(
346
                        'trac', 'locale/%s/LC_MESSAGES/messages.mo' % dirname))]
342
                        'trac', 'locale/%s/LC_MESSAGES/messages.mo' % dirname)]
347
            if 'en_US' not in locales:
343
            if 'en_US' not in locales:
348
                locales.append('en_US')
344
                locales.append('en_US')
349
            return locales
345
            return locales
350
-----------------------------------------------------------------------

Return to bug 482034