﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19381	Translations fail when using Latin American Spanish and Regular spanish in Chrome	Dan Loewenherz	nobody	"In Chrome I have the following languages set, in this order of precedence:

1) Latin American Spanish
2) Spanish
3) US English
4) English

The site has been localized for Spanish and renders perfectly in Firefox, Opera, and IE. When I view it in Chrome, however, it renders in English. I have cleared cache multiple times and am viewing the site in incognito. The Accept Language request header is this:

Accept-Language: es-419,es;q=0.8,en-US;q=0.6,en;q=0.4

Which is appropriate. I dug a little deeper and found this in django/utils/translation/trans_real.py

{{{

def parse_accept_lang_header(lang_string):
    """"""
    Parses the lang_string, which is the body of an HTTP Accept-Language
    header, and returns a list of (lang, q-value), ordered by 'q' values.

    Any format errors in lang_string results in an empty list being returned.
    """"""
    result = []
    pieces = accept_language_re.split(lang_string)
    if pieces[-1]:
        return []
    for i in range(0, len(pieces) - 1, 3):
        first, lang, priority = pieces[i : i + 3]
        if first:
            return []
        priority = priority and float(priority) or 1.0
        result.append((lang, priority))
    result.sort(key=lambda k: k[1], reverse=True)
    return result
}}}

With the header string I gave above, `pieces` becomes `['es-419,', 'es', '0.8', '', 'en-US', '0.6', '', 'en', '0.4', '']`. In the first trio, `first` resolves to `es-419,`. The conditional `if first` passes, and then the `parse_accept_lang_header` returns an empty list, basically telling anything that calls this guy that the headers have no language info, which is incorrect.

Why does `if first` fail here? What can be done to fix this?"	Bug	closed	Internationalization	1.4	Normal	duplicate			Unreviewed	0	0	0	0	0	0
