Language negotiation with cookies and .htaccess

software development

#1

Let’s see how many keywords I can stuff in this post… :slight_smile: I’m trying to set up a site that offers various languages to visitors. Automatic content negotiation IS working, but I can’t seem to get manual overriding to work. Been Googling for a couple days now, and it’s driving me nutty.

In .htaccess, I have Options +MultiViews and the “AddLanguage es .es” etc. lines. I’ve tested that, and it seems fine. If Spanish is your primary language, the Spanish version (whatever.html.es) will be returned. So far, so good. What I’d like is to have a link to allow the user to change the language, so they can see the site in English, say. I’ve set a cookie, and in .htaccess, put ‘SetEnvIf Cookie “language=(.+)” prefer-language=$1’ as the Apache docs describe (curl says the server’s running 2.0.54, so that should be ok, and mod_negotiation and mod_setenvif should be on there). Is that enough? Something’s obviously not right, since it’s not working. Any advice? Any more info needed? Thanks for any help.


#2

Bah. Total stupidity. If your cookie is set for Japanese, it helps if you have a Japanese page. Otherwise it’ll load the default one, no matter how many times you hit reload. NEVER MIND. :slight_smile: