Multilingual Apache

3 views
Skip to first unread message

Lewis G Rosenthal

unread,
Sep 29, 2009, 9:25:10 PM9/29/09
to Apache2 Mailing List
Greetings (again), everyone.

I'm spending so much time with my web server these days, my wife thinks
we've got a "thing" going on...

I am anticipating a request from a client to host a small (two pages)
site in English (now up) and Spanish. I don't want to have to go mucking
with every directory containing index.html and change it based upon the
map file, so I'm leaning toward doing this on a per-vhost basis using
MultiViews. Can anyone provide any pointers on this?

The current directory structure for this vhost is very simple:

/htdocs
/website (all html; download references include links for each language)
/images (all graphics - eight files?)
/downloadables (pdfs; two languages, based upon filename)

Ideally, the server would determine the language pref from the browser
request, and serve up either the en or es version of the single html
page under the webroot. You can't get much simpler than that. ;-)

TIA

--
Lewis
-------------------------------------------------------------
Lewis G Rosenthal, CNA, CLP, CLE
Rosenthal & Rosenthal, LLC www.2rosenthals.com
Need a managed Wi-Fi hotspot? www.hautspot.com
Secure, stable, operating system www.ecomstation.com
-------------------------------------------------------------

Steven Levine

unread,
Sep 29, 2009, 10:23:39 PM9/29/09
to apa...@googlegroups.com
In <4AC2B376...@2rosenthals.com>, on 09/29/09
at 09:25 PM, Lewis G Rosenthal <lgros...@2rosenthals.com> said:

Hi,

>site in English (now up) and Spanish. I don't want to have to go mucking
>with every directory containing index.html and change it based upon the
>map file, so I'm leaning toward doing this on a per-vhost basis using
>MultiViews. Can anyone provide any pointers on this?

As you know, the httpd online help is multi-lingual. A bit of cut and
paste from the manual subdirectory should get you started. Take a look at

conf\extra\httpd-manual.conf

for the .conf settings to cut and paste.

Regards,

Steven

--
----------------------------------------------------------------------
"Steven Levine" <ste...@earthlink.net> eCS/Warp/DIY etc.
www.scoug.com www.ecomstation.com
----------------------------------------------------------------------

Joachim Benjamins

unread,
Sep 30, 2009, 4:44:39 AM9/30/09
to apa...@googlegroups.com
Lewis G Rosenthal wrote:
> Greetings (again), everyone.
>
> I'm spending so much time with my web server these days, my wife thinks
> we've got a "thing" going on...
>
> I am anticipating a request from a client to host a small (two pages)
> site in English (now up) and Spanish. I don't want to have to go mucking
> with every directory containing index.html and change it based upon the
> map file, so I'm leaning toward doing this on a per-vhost basis using
> MultiViews. Can anyone provide any pointers on this?
>
> The current directory structure for this vhost is very simple:
>
> /htdocs
> /website (all html; download references include links for each language)
> /images (all graphics - eight files?)
> /downloadables (pdfs; two languages, based upon filename)
>
> Ideally, the server would determine the language pref from the browser
> request, and serve up either the en or es version of the single html
> page under the webroot. You can't get much simpler than that. ;-)
>
> TIA
>

After fiddiling around with Apache multiviews for a while I decided this
really is not the proper way to handle multilanguage. It is polluting
your directories with multiple versions of each file and quickly becomes
a nightmare to manage.
As an alternative I implemented a language detector in PHP. Please find
it attached, it works fairly well for www.ecomstation.com.

--
Kind regards / met vriendelijke groet,

Joachim Benjamins

+------------------------------------------------------------+
| Mensys BV - The Software Catalogue for Professionals |
+------------------------------------------------------------+
| Joachim Benjamins | Email: joa...@mensys.nl |
| Crayenestersingel 65 | Phone: +31-23-5482020 |
| 2012 PG Haarlem | Fax : +31-23-5482030 |
| The Netherlands | www : http://www.mensys.nl/ |
+------------------------------------------------------------+

getlang.zip

Dave Saville

unread,
Sep 30, 2009, 5:51:01 AM9/30/09
to apa...@googlegroups.com
On Tue, 29 Sep 2009 21:25:10 -0400 Lewis G Rosenthal wrote:
>
>
>Greetings (again), everyone.
>
>I'm spending so much time with my web server these days, my wife thinks
>we've got a "thing" going on...
>
>I am anticipating a request from a client to host a small (two pages)
>site in English (now up) and Spanish. I don't want to have to go mucking
>with every directory containing index.html and change it based upon the
>map file, so I'm leaning toward doing this on a per-vhost basis using
>MultiViews. Can anyone provide any pointers on this?
>
>The current directory structure for this vhost is very simple:
>
>/htdocs
> /website (all html; download references include links for each language)
> /images (all graphics - eight files?)
> /downloadables (pdfs; two languages, based upon filename)
>
>Ideally, the server would determine the language pref from the browser
>request, and serve up either the en or es version of the single html
>page under the webroot. You can't get much simpler than that. ;-)

Hi Lewis

Yup, ClipView page is multiview.

You need to set "Options Multiviews" under the virtual host . Note this
can be at the directory level.

And in htpd.conf:

Required modules: mod_mime, mod_negotiation

# Multi-language error messages
Include conf/extra/httpd-multilang-errordoc.conf
# Language settings
Include conf/extra/httpd-languages.conf

They should not need any modifications. But the last above can be
tweaked for language order preference. ie if you support Klingon and
Finnish and the browser says it will take either then order says which
to serve.

Then in the HTML directory, say it is index.html you want to serve:

Name the langauge versions

index.html.<lang abbreviation from that include file above> Note that
you do *not* have an index.html anymore. Then the browser just requests
index.html and apache serves the one with the correct extension and
hence language. So clipview has

clipview.html.en English
clipview.html.fr French
clipview.html.nl Dutch
ClipView.html.de German
ClipView.html.sv Swedish

HTH

--
Regards

Dave Saville

Lewis G Rosenthal

unread,
Sep 30, 2009, 12:47:53 AM9/30/09
to apa...@googlegroups.com
Hi...

On Tue, 29 Sep 2009 19:23:39 -0700 "Steven Levine" <ste...@earthlink.net>
wrote:


>
>In <4AC2B376...@2rosenthals.com>, on 09/29/09
> at 09:25 PM, Lewis G Rosenthal <lgros...@2rosenthals.com> said:
>
>Hi,
>
>>site in English (now up) and Spanish. I don't want to have to go mucking
>>with every directory containing index.html and change it based upon the
>>map file, so I'm leaning toward doing this on a per-vhost basis using
>>MultiViews. Can anyone provide any pointers on this?
>
>As you know, the httpd online help is multi-lingual. A bit of cut and
>paste from the manual subdirectory should get you started. Take a look at
>
> conf\extra\httpd-manual.conf
>
>for the .conf settings to cut and paste.
>

Thanks. This I know. The point of my post is that while I know the *how* of
it, I'm interested in experiences with the "what happens" of it. For
example, I have read here and there that MultiViews has some unintended
consequences, e.g., relating to Googlebot and the manner in which non-html
pages accessed via MultiViews return 406 errors unless worked around in the
conf (AddHandler tweaks). I'm interested to hear if there are any other
gotchas not described in the offical docs or in the confs already. ;-)

___
Lewis G Rosenthal
Rosenthal a Rosenthal, LLC
Sent with SnapperMail

Lewis G Rosenthal

unread,
Sep 30, 2009, 4:56:03 PM9/30/09
to apa...@googlegroups.com
Following up on subsequent responses which arrived before my initial one:

On 09/30/09 12:47 am, Lewis G Rosenthal thus wrote :


> Hi...
>
> On Tue, 29 Sep 2009 19:23:39 -0700 "Steven Levine" <ste...@earthlink.net>
> wrote:
>

<snip>


> ___
> Lewis G Rosenthal
> Rosenthal a Rosenthal, LLC
> Sent with SnapperMail
>
>

Hehehe... That's what I get for leaving a reply in my Snappermail outbox
on my phone until the next morning. :-)

Joachim: Thanks, I'll have a look at the php ASAP. I've read mixed
reviews (no pun intended) of multiviews, and was not sure which way to
go. I just don't want to have to set this at the server-wide level,
especially if I only have one or two multi-language sites (though
Esperanto is *always* fun to have around - plus, it makes people think
you're "hip" and "smart!")...

Dave: I've read conflicting issues surrounding whether to prepend the
language delimiter (index.en.html) or to tack it on *after* the
extension, per your example.
(http://www.seocentro.com/articles/apache/mod_rewrite-seo-purposes.html
has an interesting article on "fixing up" URLs for SEO - see page 6 for
some interesting code, here; I read a couple other articles, which
escape my grasp at the moment, contrasting the two methods.)

Thanks again, guys. You've given me plenty to think about. This
particular site, having but one real content page (shameless plug to
increase hits: http://www.e118thstaffordables.com ) may be a good
candidate for MultiViews, but Joachim, your point about multiple pages
in each directory is well taken, indeed.

Cheers/2

Steven Levine

unread,
Sep 30, 2009, 8:50:55 PM9/30/09
to apa...@googlegroups.com
In <4AC3C5E...@2rosenthals.com>, on 09/30/09

at 04:56 PM, Lewis G Rosenthal <lgros...@2rosenthals.com> said:

Hi,

>I just don't want to have to set this at the server-wide level,

It definitely does not have to be server wide or even host wide.

>Dave: I've read conflicting issues surrounding whether to prepend the
>language delimiter (index.en.html) or to tack it on *after* the
>extension, per your example.

The nice thing about stuffing it in the middle is that eCS associations
continue to work. I'm pretty sure it should be possible to put each set
of language files in a separate directory with approprate rewriting rules.

Lewis G Rosenthal

unread,
Sep 30, 2009, 10:50:12 PM9/30/09
to apa...@googlegroups.com
On 09/30/09 08:50 pm, Steven Levine thus wrote :

> In <4AC3C5E...@2rosenthals.com>, on 09/30/09
> at 04:56 PM, Lewis G Rosenthal <lgros...@2rosenthals.com> said:
>
> Hi,
>
>
>> I just don't want to have to set this at the server-wide level,
>>
>
> It definitely does not have to be server wide or even host wide.
>
>
I just realized that AddHandler can be set at the vhost level, so this
does make it much easier. I was thinking that these had to be set at the
server level.

>> Dave: I've read conflicting issues surrounding whether to prepend the
>> language delimiter (index.en.html) or to tack it on *after* the
>> extension, per your example.
>>
>
> The nice thing about stuffing it in the middle is that eCS associations
> continue to work. I'm pretty sure it should be possible to put each set
> of language files in a separate directory with approprate rewriting rules.
>
That would make sense.

Dave Saville

unread,
Oct 1, 2009, 2:31:03 AM10/1/09
to apa...@googlegroups.com
On Wed, 30 Sep 2009 22:50:12 -0400 Lewis G Rosenthal wrote:
>
>
>On 09/30/09 08:50 pm, Steven Levine thus wrote :
>> In <4AC3C5E...@2rosenthals.com>, on 09/30/09
>> at 04:56 PM, Lewis G Rosenthal <lgros...@2rosenthals.com> said:
>>
>> Hi,
>>
>>
>>> I just don't want to have to set this at the server-wide level,
>>>
>>
>> It definitely does not have to be server wide or even host wide.
>>
>>
>I just realized that AddHandler can be set at the vhost level, so this
>does make it much easier. I was thinking that these had to be set at the
>server level.

I said the option can be at the directory level :-)

>>> Dave: I've read conflicting issues surrounding whether to prepend the
>>> language delimiter (index.en.html) or to tack it on *after* the
>>> extension, per your example.
>>>
>>
>> The nice thing about stuffing it in the middle is that eCS associations
>> continue to work. I'm pretty sure it should be possible to put each set
>> of language files in a separate directory with approprate rewriting rules.

Can't recall why I chose tagging the end - I think it was less work at
the time - and the pages don't change that often.

--
Regards

Dave Saville

Lewis G Rosenthal

unread,
Oct 1, 2009, 2:57:45 PM10/1/09
to apa...@googlegroups.com
Hi, Dave...

On 10/01/09 02:31 am, Dave Saville thus wrote :


> On Wed, 30 Sep 2009 22:50:12 -0400 Lewis G Rosenthal wrote:
>
>> On 09/30/09 08:50 pm, Steven Levine thus wrote :
>>
>>> In <4AC3C5E...@2rosenthals.com>, on 09/30/09
>>> at 04:56 PM, Lewis G Rosenthal <lgros...@2rosenthals.com> said:
>>>
>>> Hi,
>>>
>>>
>>>
>>>> I just don't want to have to set this at the server-wide level,
>>>>
>>>>
>>> It definitely does not have to be server wide or even host wide.
>>>
>>>
>>>
>> I just realized that AddHandler can be set at the vhost level, so this
>> does make it much easier. I was thinking that these had to be set at the
>> server level.
>>
>
> I said the option can be at the directory level :-)
>
>

We were talking about MultiViews; the AddHandler directive to which I
was referring is for type maps. I knew that MultiViews could be set at
the server, vhost, or directory levels; I wasn't thinking that
AddHandler could be included in a vhost config. ;-)

...And the reason for my not thinking in that direction is that *all* of
my AddHandler directives are currently server-wide.


>>>> Dave: I've read conflicting issues surrounding whether to prepend the
>>>> language delimiter (index.en.html) or to tack it on *after* the
>>>> extension, per your example.
>>>>
>>>>
>>> The nice thing about stuffing it in the middle is that eCS associations
>>> continue to work. I'm pretty sure it should be possible to put each set
>>> of language files in a separate directory with approprate rewriting rules.
>>>
>
> Can't recall why I chose tagging the end - I think it was less work at
> the time - and the pages don't change that often.
>
>

Sounds logical!

Reply all
Reply to author
Forward
0 new messages