in reply to Language Negotiation with mod_perl, Apache

From the Apache 1.3 documentation:

Variants with no Language

If some of the variants for a particular resource have a language attribute, and some do not, those variants with no language are given a very low language quality factor of 0.001.

The reason for setting this language quality factor for variant with no language to a very low value is to allow for a default variant which can be supplied if none of the other variants match the browser's language preferences. This allows you to avoid users seeing a "406" error page if their browser is set to only accept languages which you do not offer for the ressource that was requested.

For example, consider the situation with Multiviews enabled and three variants:

The meaning of a variant with no language is that it is always acceptable to the browser. If the request is for foo and the Accept-Language header includes either en or fr (or both) one of foo.en.html or foo.fr.html will be returned. If the browser does not list either en or fr as acceptable, foo.html will be returned instead. If the client requests foo.html instead, then no negotation will occur since the exact match will be returned. To avoid this problem, it is sometimes helpful to name the "no language" variant foo.html.html to assure that Multiviews and language negotiation will come into play.

Wouldn't that solve your problem, rather than fiddling with the headers in the request?

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Replies are listed 'Best First'.
Re[2]: Language Negotiation with mod_perl, Apache
by penguinfuz (Pilgrim) on Jan 31, 2003 at 10:01 UTC
    WARNING: Comment Contains No Perl

    CountZero, I was not aware that a default 'no language' variant could be returned reliably. I say 'reliably' because my understanding (and _some_ testing) showed that when the client did not list a language that I have translations for, Apache would return the variant based on it's alphabetical order.

    Note that my test included file names such as:

    index.html.de
    index.html.en

    And then I simply request index.html and let multiviews run. As described above, if I understand correctly, I could have files like:

    index.html.de
    index.html.en
    index.html

    And simply link to the pages like <a href="index">Go Here!</a> Unfortunately I have way too many links that would need to be modified for this to work. Hence the request header fiddling! ;)

      It is even a bit more involved than that: you would really like to have a file called index.html.html to avoid that someone requests index.html and does not trigger the multiview-feature.

      Of course, you could write a Perl-script that modifies your links. (There now this comment has a Perl-content ;-) )

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law