Hello fellow monks -- I seek all wisdom and advise!
I am serving a website in (2) languages, and wish to do so without requiring the visitor to make the selection. I have shifted the heavy lifting to mod_perl because visitors who have no language support for either of my translations get a nasty 406 error. Limitation of multiviews (as implemented in Apache 1.x).
So... Easy enough with mod_perl
<grin>
My request for advise is this:
Which operation would be more costly, checking the contents of
$r->header_in('Accept-Language') with a regexp (de and en for example) or just tacking on the default language (with a low quality rating) for all request and forget about it! The website has a considerable amount of traffic and of course I want to keep all access 'snappy'.
Obligatory code example:
...
# Everyone gets English language support added
my $lang = $r->header_in('Accept-Language');
$r->header_in('Accept-Language', $lang . ', en;q=0.20');
return OK;
Or...
...
# English language added as failsafe
my $lang = $r->header_in('Accept-Language');
if ($lang !~ /en/ || $lang !~ /de/) {
$r->header_in('Accept-Language', $lang . ', en;q=0.20');
return OK;
} else {
return OK;
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.