@waltd:
Here is a short overview about language-based content negotiation:
Pre-requisites on the server-side (not related to FW):
-
module mod_negotiation available and active (should be the default).
-
In the config file, add a line like “AddHandler type-map var” to allow recognition of .var as a type-map. Alternatively it can be placed in a .htaccess file to limit this content negotiation to a given directory only.
-
When accessing directories without explicitly calling the .var file, then an index.var (or appropriate) must be set as one of the default filenames to look for when accessing a directory). In the following I assume that we use “index.var”.
Structure of an index.var file:
URI: RelFileToCall
Content-type: text/html
Content-language: LanguageShortRFC1766
URI: RelFileToCall
Content-type: text/html
(For any reason, the board software does not let me write the file correctly; there must be just an empty line between each entry, not between “URI/Content-type/Content-language”. Strange. Anyway, you find examples at the reference links below.)
** URI:
Contains the file being referred to relative from the location of the .var file. Since usually all files are in the same folder, just placing the filename there is sufficient.
The URI must point to a local file, so you cannot call an URL like http://www.other.tld this way (at least it is limited in Apache 1.3. and I feel we should do the most compatible way).
** Content-type:
The negotiation feature can be used for many other purposes, but for our application the line can be simply used as it is and does not need to be changed. Likely you could even skip it, but in all examples I reviewed, language-based negotiations had this line as well.
An example where it changes could be allowing text-based browsers like Lynx to show an ASCII art instead of a JPEG file. Then of course, you would need to adjust this line pointing to an image type at one entry and to a text file for the other entry.
** Content-language:
Here we place the language shortcut according RFC 1766. This is the most important line, since it makes Apache to decide which file to call for which language. Typical values are “de”, “en”, “fr” (German, English, French). You can also go more into details like “de-ch” (Swiss-German), but not sure if this is really useful.
An important thing to mention is the last entry in my sample file above, which does not have a content-language line. Consider that you allow decision between German, English and French - but a Japanese user may get a 406 error message that there is no appropriate content for him. While he will see the available options, it is bad behaviour. You either may catch the error on the server by implementing an error redirect, but it is better to have this line which is used if no other one matches.
A sample index.var file:
URI: index_de.html
Content-type: text/html
Content-language: de
URI: index_en.html
Content-type: text/html
Content-language: en
URI: index_fr.html
Content-type: text/html
Content-language: fr
URI: index_alternative.html
Content-type: text/html
Freeway action:
I could imagine that we have the following GUI for this folder action:
-
An edit field that allows to type in the name of the .var file being used (maybe good idea to have “index.var” being the default).
-
Two drop-down boxes and an file button forming one entry: “Content-type” selector (you may provide a list of MIME types or simply just text/html or even skip this and hardcode text/html at all), “Language selector” showing the language codes, “File selector” button to choose a file.
More additions:
Content negotiation also provides some other features like using a quality factor for each content type; this would make sense not for language-based negotiation (at least in my mind), but more when having different content types available. For example, there is a decision made between a GIF, a JPEG and an ASCII art. If a browser can show all three types, the quality factor could be used to prefer the JPEG and - if this is not available - use the GIF instead.
The quality factor ranges between 0.000 and 1.000; variants using a factor of 0 are never chosen however.
A short example:
URI: image.jpeg
Content-type: image/jpeg; qs=0.9
URI: image.gif
Content-type: image/gif; qs=0.5
URI: alternative.txt
Content-type: text/plan; qs=0.1
I found no guidelines about how to use the quality factor, neither on Apache’s official documentation nor anywhere else. Guess you a have to play with the values
Anyway, the definitively can be above 1 in total (so it is not a percentage based scheme).
Not sure if you want to include this; languages are definitively selected not in this way, since even your browser is set to accept English and German and you have both entries in the .var file, the browser decides which to use according the priority set at software preferences.
Let me know if anything is unclear and needs more discussion. You may also find the following resources helpful:
http://httpd.apache.org/docs/1.3/content-negotiation.html
http://httpd.apache.org/docs/1.3/mod/mod_negotiation.html
http://www.cs.tut.fi/~jkorpela/multi/6-en.htm
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options