mozilla / playdoh

PROJECT DEPRECATED (WAS: "Mozilla's Web application base template. Half Django, half awesomeness, half not good at math.")
BSD 3-Clause "New" or "Revised" License
710 stars 107 forks source link

zh-TW should not default to zh-CN if it isn't available. #100

Open Osmose opened 12 years ago

Osmose commented 12 years ago

We've gotten feedback from localizers that zh-TW falls back to zh-CN if zh-TW is unavailable. It should fall back to en-US instead regardless of whether zh-CN is available or not. This is probably an issue in LocaleURLMiddleware.

fwenzel commented 12 years ago

What do their accept-language headers look like, exactly? zh-TW should never fall back to zh-CN anyway, according to: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4

If we fuzzy-match like this, then our code has a bug. But to determine this we should get their Accept-Language headers and make sure those reflect their preferences first. Thanks!

Osmose commented 12 years ago

Looked into this a bit. Turns out this was the desired behavior when the code was written due to how IE7/8 uses ja-JP for Japanese, not ja as AMO used. https://bugzilla.mozilla.org/show_bug.cgi?id=439568#c27 explains the solution they came to.

The code from that patch went into Zamboni, which is where we took the code ourselves. Specifically, https://github.com/mozilla/funfactory/blob/master/funfactory/urlresolvers.py#L93 is what adds zh: zh-CN to the langs map, which in turn matches zh-TW on line 101 below.

The problem also exists if you try to go to zh-TW via the URL thanks to find_supported https://github.com/mozilla/funfactory/blob/master/funfactory/urlresolvers.py#L35, which matches the prefix only.

So do we want to stick to the RFC, or keep the hybrid approach from before? And, if we keep the hybrid, do we want to add in a special exception for zh-TW?

IMO following the RFC is the right choice. Playdoh doesn't really have the benefit of considering the browser share of site visitors since it powers many different sites.

fwenzel commented 12 years ago

Btw, there are a bunch of tests for this code here: https://github.com/mozilla/input.mozilla.org/blob/master/apps/input/tests/test_middleware.py

We should uplift those into funfactory, they are generic enough. That said, they obviously currently test the behavior you describe, not the behavior the standard suggests.

milossh commented 12 years ago

http://hg.mozilla.org/releases/l10n/mozilla-aurora/zh-TW/file/d615e34c28c5/toolkit/chrome/global/intl.properties#l24

has it that zh-TW Firefox sends: "intl.accept_languages=zh-tw, en-us, en".