Ticket #6409: lang-code-fix.diff
File lang-code-fix.diff, 1.6 KB (added by , 17 years ago) |
---|
-
django/utils/translation/trans_real.py
357 357 return lang_code 358 358 359 359 accept = request.META.get('HTTP_ACCEPT_LANGUAGE', '') 360 for lang, unused in parse_accept_lang_header(accept):361 if lang == '*':360 for accept_lang, unused in parse_accept_lang_header(accept): 361 if accept_lang == '*': 362 362 break 363 363 364 364 # We have a very restricted form for our language files (no encoding … … 366 366 # language each time. So we avoid the overhead of gettext.find() and 367 367 # look up the MO file manually. 368 368 369 normalized = locale.locale_alias.get(to_locale( lang, True))369 normalized = locale.locale_alias.get(to_locale(accept_lang, True)) 370 370 if not normalized: 371 371 continue 372 372 … … 378 378 # need to check again. 379 379 return _accepted[normalized] 380 380 381 for lang in ( normalized, normalized.split('_')[0]):381 for lang in (accept_lang, accept_lang.split('-')[0]): 382 382 if lang not in supported: 383 383 continue 384 langfile = os.path.join(globalpath, lang, 'LC_MESSAGES', 384 normalized = locale.locale_alias.get(to_locale(lang, True)).split('.')[0] 385 langfile = os.path.join(globalpath, normalized, 'LC_MESSAGES', 385 386 'django.mo') 386 387 if os.path.exists(langfile): 387 388 _accepted[normalized] = lang