Re:Accept my accept-language
by spacehunt on Sunday March 16, 2014 @09:32AM
(#7409342)
Please don't do this... I detest sites that try to be clever and serve me Simplified Chinese even though I only have zh-hk in Accept-Language:.
[ Parent
| on HN ]
I already have exceptions for things like that. I think our code handles zh_{CN,TW,HK} separately, as well as things like pt_BR vs. pt.
> curl -I -H 'Accept-Language: zh-hk,en;q=0.8' https://dolphin-emu.org/
HTTP/1.1 200 OK # No zh_HK translation (yet!)
> curl -I -H 'Accept-Language: zh-cn,en;q=0.8' https://dolphin-emu.org/
HTTP/1.1 302 FOUND
Location: http://cn.dolphin-emu.org/?cr=cn
> curl -I -H 'Accept-Language: pt,en;q=0.8' https://dolphin-emu.org/
HTTP/1.1 200 OK # No pt translation (yet!)
> curl -I -H 'Accept-Language: pt-br,en;q=0.8' https://dolphin-emu.org/
HTTP/1.1 302 FOUND
Location: http://br.dolphin-emu.org/?cr=br
i18n is hard but I think I've been doing a fairly good job on it. Proud to have more than 50% of our visitors from outside of the US!Having now read the full code and not just the diff, I have to say it looks pretty good. I note that plain "zh" is not redirected to the cn site. ;) Whether it should or not is debatable though -- I actually think ignoring "zh" altogether is a rather prudent move if it is intentional.