Ticket #5494: root-locale-js-catalog.diff

File root-locale-js-catalog.diff, 1.1 KB (added by trevor@…, 17 years ago)

Patch that supplies the option of specifying an empty string as a package for js l10n.

  • django/views/i18n.py

     
    110110        packages = ['django.conf']
    111111    if type(packages) in (str, unicode):
    112112        packages = packages.split('+')
    113     packages = [p for p in packages if p == 'django.conf' or p in settings.INSTALLED_APPS]
     113    packages = [p for p in packages if p == 'django.conf' or p == '' or p in settings.INSTALLED_APPS]
    114114    default_locale = to_locale(settings.LANGUAGE_CODE)
    115115    locale = to_locale(get_language())
    116116    t = {}
    117117    paths = []
    118118    # first load all english languages files for defaults
    119119    for package in packages:
    120         p = __import__(package, {}, {}, [''])
    121         path = os.path.join(os.path.dirname(p.__file__), 'locale')
     120        if p == '':
     121            path = 'locale'
     122        else:
     123            p = __import__(package, {}, {}, [''])
     124            path = os.path.join(os.path.dirname(p.__file__), 'locale')
    122125        paths.append(path)
    123126        try:
    124127            catalog = gettext_module.translation(domain, path, ['en'])
Back to Top