Ticket #5494: js_catalog_r9076.diff
File js_catalog_r9076.diff, 2.3 KB (added by , 16 years ago) |
---|
-
django/views/i18n.py
121 121 packages = ['django.conf'] 122 122 if type(packages) in (str, unicode): 123 123 packages = packages.split('+') 124 packages = [p for p in packages if p == 'django.conf' or p in settings.INSTALLED_APPS]125 124 default_locale = to_locale(settings.LANGUAGE_CODE) 126 125 locale = to_locale(get_language()) 127 126 t = {} 128 127 paths = [] 129 # first load all english languages files for defaults130 128 for package in packages: 131 129 p = __import__(package, {}, {}, ['']) 132 130 path = os.path.join(os.path.dirname(p.__file__), 'locale') 133 131 paths.append(path) 134 try: 135 catalog = gettext_module.translation(domain, path, ['en']) 136 t.update(catalog._catalog) 137 except IOError: 138 # 'en' catalog was missing. This is harmless. 139 pass 140 # next load the settings.LANGUAGE_CODE translations if it isn't english 141 if default_locale != 'en': 132 # A list of locales to load. Fallbacks for the requested locale 133 # are settings.LANGUAGE_CODE and 'en', in that order 134 locales = ['en'] 135 # Two checks: one to avoid dupes, and another one to skip this 136 # fallback if the requested language is 'en' 137 if default_locale != 'en' and locale != 'en': 138 locales.append(default_locale) 139 if locale not in locales: 140 locales.append(locale) 141 for loc in locales: 142 142 for path in paths: 143 143 try: 144 catalog = gettext_module.translation(domain, path, [ default_locale])144 catalog = gettext_module.translation(domain, path, [loc]) 145 145 except IOError: 146 146 catalog = None 147 147 if catalog is not None: 148 148 t.update(catalog._catalog) 149 # last load the currently selected language, if it isn't identical to the default.150 if locale != default_locale:151 for path in paths:152 try:153 catalog = gettext_module.translation(domain, path, [locale])154 except IOError:155 catalog = None156 if catalog is not None:157 t.update(catalog._catalog)158 149 src = [LibHead] 159 150 plural = None 160 151 if '' in t: