This question might me hilarious obvious but ... I have searched the web and stack overflow but did not find a satisfying answer.
What makes a good start for adding language selection to a web site?
My urls will be
example.com/de/ example.com/en/
to indicate the current language, plus a cookie set after I determined the initial language.
Upon landing on example.com I will check for a (recent) cookie first, then for ACCEPT_LANG then if a specifiy url is given with /en/, /de/.
The language will always be part of the url to allow bookmarking, i.e. I will redirect to example.com/de/ if I have determined that the users intention is to see the site in German.
Now my question: What is the preferred way these days to signal the server the users choice? I am not talking about the visual selection (drop down vs. language list à la wikipedia) nor geolocating vs ACCEPT_LANG but the user signaling the server. I have in mind: (Assuming the user is on English site and wants to switch to German site)
- Do client-side javascript wizardry and alter location.href s//en///de/
- Pre-render the language alter link on the server (Would give me a chance to suppress links for non-existing translations)
- Post-back to example.com?lang=de&orig= which does the response redirection. Would give me the chance to re-fill form variables if the user decides to switch the language while filling out fields, but I am not certain on this point.
Other possibilities or what is the best technically seen?