I'm developing a website that needs to be available in 3 languages (static content only, to be served by Apache). I would like to make use of the language detection features so that the user already fell into a version compatible with the language preferences of his browser , but also want him to choose a different language through special links . Is it possible to do this by Apache without the use of some server-side language?
I started reading the documentation on content negotiation and about mod_negotiation
, but I'm pretty lost, because the examples given do not seem clear to me. What I understood so far (please correct me if I'm wrong) was as follows:
- I must create my pages according to a specific convention, eg
index.html.pt
,index.html.en
,index.html.ja
; -
I should set
Directory
to enable content negotiation:<Directory /var/www/vhosts/example.com/httpdocs> Options Indexes FollowSymLinks MultiViews DirectoryIndex index.html AllowOverride None Order allow,deny allow from all LanguagePriority en pt ja ForceLanguagePriority Prefer Fallback </Directory>
-
Each page should link to the base name, without specifying the language, eg
href="index.html"
.
With this, from what I understand the server will be able to choose a version based on the header Accept-Language
that the browser sends. If that is correct, the first part is ok.
However, I have no idea how I could over a link change the current language of the page - and do it so that it continues to be the current language even after the user clicks on other links. The documentation mentions "advanced techniques (such as cookies or special URL-paths)," but I could not understand what it was, and the linked documentation did not help much. Is there a simple way to do this? Give preference, without needing JavaScript (but if you do not have another way, that's fine).