Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How can I make my website detect a visitor’s language setting?

How can I make my website detect a visitor’s language setting?
Thread Tools
Forum Regular
Join Date: Dec 2009
Status: Offline
Reply With Quote
Jan 8, 2010, 05:15 PM
 
Sorry if this is too basic, but I don’t seem to be up to working this out for myself today (quite drunk).

The thing is, I’m in the process of setting up a hybrid English and German website, and I would like to know how I can automatically re‑direct visitors to the appropriate version corresponding to their default language settings.

IP location does not cut it (expats), I need to pull the system language from somewhere.

Spanks.
     
Fresh-Faced Recruit
Join Date: Jan 2010
Status: Offline
Reply With Quote
Jan 9, 2010, 05:21 PM
 
Sure this is an easy one !
You need to check the value of the HTTP header: Accept-Languages
It should contains the prefered language in the order the user would like to see the web site. You can read more in section 14.4 of HTTP/1.1: Header Field Definitions

Stéphane
Welcome | TouchMatter
Give an app a chance with TapPerso 1.0
     
dedalus  (op)
Forum Regular
Join Date: Dec 2009
Status: Offline
Reply With Quote
Jan 10, 2010, 06:07 AM
 
Thank you. I would enter that into my .htaccess file, right?

Interesting app, by the way. I like the idea.
     
Moderator
Join Date: Mar 2004
Location: Copenhagen
Status: Offline
Reply With Quote
Jan 10, 2010, 05:12 PM
 
No, you’d have to load it as a variable in your script, and then serve up the corresponding page based on the contents of that variable.
     
dedalus  (op)
Forum Regular
Join Date: Dec 2009
Status: Offline
Reply With Quote
Jan 11, 2010, 06:55 AM
 
Are you sure?

The way I understand this site here, it should be possible to define it in .htaccess:
Caching Tutorial for Web Authors and Webmasters

I was really hoping I could do it this way, seems more elegant than PHP.
     
Moderator
Join Date: Mar 2004
Location: Copenhagen
Status: Offline
Reply With Quote
Jan 11, 2010, 07:45 AM
 
This would appear to indicate that you’re right. As long as you’re willing to use mod_rewrite, as well, you can 301-redirect the user to a language-specific page. I never even considered that way of doing it (probably because I rarely use .htaccess for much at all).
     
dedalus  (op)
Forum Regular
Join Date: Dec 2009
Status: Offline
Reply With Quote
Jan 12, 2010, 07:27 AM
 
That does sound pretty definitive. Great find, thanks Oisín.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:54 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2