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 (-2 / +14 lines)
Lines 32-38 Link Here
32
        return []
32
        return []
33
else:
33
else:
34
    from babel import Locale
34
    from babel import Locale
35
    from babel.core import LOCALE_ALIASES
35
    from babel.core import LOCALE_ALIASES, UnknownLocaleError
36
    from babel.dates import (
36
    from babel.dates import (
37
        format_datetime as babel_format_datetime,
37
        format_datetime as babel_format_datetime,
38
        format_date as babel_format_date,
38
        format_date as babel_format_date,
Lines 373-378 Link Here
373
    if locale == 'iso8601':
373
    if locale == 'iso8601':
374
        return 1 # Monday
374
        return 1 # Monday
375
    if babel and locale:
375
    if babel and locale:
376
        if not locale.territory:
377
            # search first locale which has the same `langauge` and territory
378
            # in preferred languages
379
            for l in req.languages:
380
                l = l.replace('-', '_').lower()
381
                if l.startswith(locale.language.lower() + '_'):
382
                    try:
383
                        l = Locale.parse(l)
384
                        if l.territory:
385
                            locale = l
386
                            break
387
                    except UnknownLocaleError:
388
                        pass
376
        if not locale.territory and locale.language in LOCALE_ALIASES:
389
        if not locale.territory and locale.language in LOCALE_ALIASES:
377
            locale = Locale.parse(LOCALE_ALIASES[locale.language])
390
            locale = Locale.parse(LOCALE_ALIASES[locale.language])
378
        return (locale.first_week_day + 1) % 7
391
        return (locale.first_week_day + 1) % 7
379
-----------------------------------------------------------------------

Return to bug 482034