Sniffing for language

Here’s a good question.

We’re about to launch a new site which will appear in English, Dutch and French. As the site isn’t very large, we’re currently planning on running the three languages in parallel, and having language selection buttons on the English home page.

Is there a nice simple way to sniff for the language used by the browser and redirect the visitor to the appropriate site?

Thanks

Heather


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You would need to get the ACCEPT_LANGUAGE header from the browser and parse it. This is not trivial, because the content of that header is an array of possible languages, each with a different “weight” attribute to govern the fallback order.

If you are running on an Apache server, you should look to see if it has the mod_content_negotiation module installed and enabled. I have an Action that will do everything you need if you have that enabled on your server.

What you would have to do is create (number of languages + 1) home pages for your site, with their filenames precisely like this (for example, if you wanted english and spanish):

index_en.html
index_es.html
index_alternative.html

Then apply the action to the site folder and publish. A new file called index.var will be generated, and the server will work out all of the nuances of which language to serve, in which order, for you.

That index_alternative.html at the end there (and it must be the last [bottom-most] “index” page in your site as listed in the Site pane in Freeway) is there to catch anyone who has specified that they cannot accept any of the preceding languages, not even as a last resort. What would you put on that page? Maybe the Esperanto version? I don’t know…

As far as how you structure the rest of the site, one idea would be to have each language in a separate folder within Freeway, with only the language home pages in the outer-most site folder.

One gotcha to consider: the last page in the folder you’ve applied the Action to will be “dirty” on every publish. So if you have a heavy page at the bottom of the list in your Site pane, you might want to put a blank page after it, just to speed up publishing and uploading. This is something that I had to do in order to keep the index.var file in synch with the site at all times – it’s the result of an Actions API bug.

ContentNegotiation Action is in the usual place: http://freewaypro.com/actions/downloads and if you search the archives here, you will find a thread about it, and somebody who has used it in production (I haven’t).

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

And after all Walter’s erudite, if daunting, advice, remember that
just because someone’s computer appears to be in one language doesn’t
mean that that’s the preferred one for the user. Earlier this month a
guy I met in Turkey asked me for help getting his Windows PC laptop
to be properly in Turkish rather than ‘English with Turkish options
enabled’, which is how it seemed to be.

(No, I failed. But I don’t think it was possible short of a complete
reinstall.)

Consider giving people options rather than making choices for them. Seriously!

k


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

On 21 Aug 2008, at 18:14, waltd wrote:

If you are running on an Apache server

I think this is quite possible, as the site in question will be hosted
by ineedwebhosting. Thank you for the comprehensive answer there,
Walter.

However, for the sake of three languages, and barely more pages per
site, I think I shall err on the side of Keith in this instance, so
it’ll be English as the “master” site, with microsites in Dutch and
French, arrived at via buttons on the respective home pages.

As ever, this list is educational.

Cheers

Heather


“Freeway - Web Design for All”


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Heather,

Yes, we support mod_content if you mean this. I can’t find any reference for mod_content_negotiation though, Even if I Google it.

David

On 21 Aug 2008, at 19:23, Heather Kavanagh wrote:

On 21 Aug 2008, at 18:14, waltd wrote:

If you are running on an Apache server

I think this is quite possible, as the site in question will be hosted
by ineedwebhosting. Thank you for the comprehensive answer there,
Walter.

David Owen
http://www.ineedwebhosting.co.uk

Here’s the reference from Apache:

http://httpd.apache.org/docs/1.3/content-negotiation.html

The mod_ part might have been throwing you off, that’s the name of
the file that gets included into Apache at run-time.

Walter

On Aug 22, 2008, at 12:39 PM, David Owen wrote:

Heather,

Yes, we support mod_content if you mean this. I can’t find any
reference for mod_content_negotiation though, Even if I Google it.

David

On 21 Aug 2008, at 19:23, Heather Kavanagh wrote:

On 21 Aug 2008, at 18:14, waltd wrote:

If you are running on an Apache server

I think this is quite possible, as the site in question will be
hosted
by ineedwebhosting. Thank you for the comprehensive answer there,
Walter.

David Owen
http://
www.ineedwebhosting.co.uk_____________________________________________
__
freewaytalk mailing list
email@hidden
Update your subscriptions at:
List Options | FreewayTalk


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options