Multilingual versions of documents

Nearly all browsers support an option to automacically select a document in a desired format.

Naming of multilingual documents

Multiple documents have to be created first for each desired language. In addition to the normal file suffix another suffix is appended to the filename for the given language. A list of used language abbreviations is given in RFC1766. All suffixes can be permutated, but putting the language at the end has several advantages.

Example

A document in HTML shall be presented in six languages:

LanguageCountrycodeDocumentname
germandeindex.html.de
englishenindex.html.en
spanishesindex.html.es
frenchfrindex.html.fr
norwegiannoindex.html.no
swedishseindex.html.se
japanesejpindex.gif.jp

Links to multilingual documents

To access documents you can keep your old documents: You can link your documens with full name (including the language suffix) or only the part of the filename, which is commen to all versions. Even the suffix for the file format can be stripped, so the server can select the right file from the desired formats.

Example

In addition to the example above, links select different documents:

Link Possible results
<a href="index.html.en"> only the english variant
<a href="index.html"> All variants in HTML
<a href="index"> All variants in all languages and formats

Selection by browser and server

Dependent on the configuration of browser and server different results will be displayed to the user:

Example

Configured language Requested URL Returned document Description
- index.html index.html.de Selected by LanguagePriority
- index.html.jp Error message for nonexisting URL This variante does not exist
en index.html index.html.en The document does exist in the requested language
fi,no,fr index.html index.html.fr Finnish is unknown, a norwegian variant does not exist, but a french one
it,po index List of all variants There is no italian or polish version the user understands, so he can select one himself.

Hint: When multiple versions are given for an index page, all files should end with a language suffix. If the file index.html still exists, this file is allways returned and no automatic selection is done when links point to homedir/index.html or homedir/. By specifying LanguagePriority the server allways returns a document, if the URL requested does not exist.

Additional informations

Instead of selecting documents by suffix, a file named with the common filename and the suffix .var can be provided, which lists all variants. The benefits are, additional informations can be provided and the files don't have to be named to the strict naming pattern. For each variant the file contains an introduction URI: filename followed by Content-type: to specify the MIME type, Content-language: to specify the language or Content-encoding:, if the files are compressed. For the type tag an optional token qs=0.2 specifies the quality of this variant, which is considered for selection. A full description is available on the Apache web-site.

Example

For the index document the following variants are described in index.var:

URI: index

URI: index.html.de
Content-type: text/html
Content-language: de

URI: index.txt
Content-type: text/plain; qs=0.01
Content-language: en

URI: index.html.de.gz
Content-type: text/html
Content-language: de
Content-encoding: x-gzip

On tmgo.free.fr is a script, which displayes the Accept-Language-HTTP-header as sent by the browser.