Translations fail when using Latin American Spanish and Regular spanish in Chrome
|Reported by:||dloewenherz||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
In Chrome I have the following languages set, in this order of precedence:
1) Latin American Spanish
3) US 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:
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, 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?