Forum Moderators: phranque
Using www.host.com/en/eo is difficult for the customer, and the brochures are printed with the "short" version (so it is not a choice anymore), and I'm, not sure that either the fr or the en or any of the languages codes are not exists in the list of these shourtcuts already. So it could be that I need www.host.com/fr for the French languaged website and I need www.host.com/fr for this shortcut thing also.
Is anyone had situation like this? Any idea or recommendation?
Any request without the language specified could default to the default site language, or to a page determined by the browser language settings based on HTTP_ACCEPT_LANGUAGE, or to a page showing language names and representative national flag icons to click on to set the language.
It is better to let the user choose than to make assumptions based on IP addresses, etc. For example, we have lots of people who speak only spanish in the U.S. Geo-IP redirection makes a lot of people mad, so let them choose manually if necessary.
Jim
There's a couple of sites which geo-traget me and through me to a certain branch or language version regardless of what I do. Even assuming the good intention of providing a nice service to me (and keeping in mind the bad intention of hiding certain areas from me) there might be a lot of valid reasons why I may WANT to visit a branch other than the one intended for me. Maybe I just want to find out what the product is called in France, what it's price is in Cananda, what the referecne customers are in Japan, who the distributor is in Iceland. Or maybe I just want to check out the section my buddy from university manages who has moved to a different country after graduating.
Give the visitor the CHOICE to visit every language version you have! There's Spanish native speakers in Japan - they'd rather visit the Spanish language version instead of the Japanese version...
I would not rely on HTTP_REFERER for any critical function such as "remembering" the user's language. As we haved discussed in many times in "hotlinking" threads here, HTTP_REFERER is often blank, especially for visitors behind caching proxies or using "internet security" software.
If you don't want to put the language in the URL, a query string, or a sessionID, then I suppose you could use cookies.
Jim
Any suggestion, recommendation or idea?
RewriteCond %{HTTP_COOKIE} ^lang=(.+)$
RewriteRule ^/(.+)\.html$ http://www.backend_server.com/handler.php?page=$1&lang=%1 [P]
RewriteCond %{HTTP_COOKIE} ^lang=(.+)$ [OR]
RewriteCond %{HTTP_COOKIE} !lang=
RewriteCond EN ^(.+)$
RewriteRule ^/(.+)\.html$ http://www.backend_server.com/handler.php?page=$1&lang=%1 [P]
Actually my config is a bit complicated because of this reason, I have a bunch of RewriteRules which is passing the original request to the back-end server for a specific xml file (and which is being translated to html on the fly), it would not be nice to put RewriteCond(s) in the front of each RewriteRule, so likely the RewriteRule for this language thing will look like this:
RewriteRule ^/(.+)\.html$ /$1.html?lang=%1 [QSA]
Yes, another rule would be needed, and you will need to use a script to set the cookie.
# If cookie exists and contains "lang=<something>, then rewrite with query string
RewriteCond %{HTTP_COOKIE} ^lang=(.+)$
RewriteRule ^/(.+)\.html$ http://www.backend_server.com/handler.php?page=$1&lang=%1 [P]
# Otherwise, redirect to default language, and tell script to set cookie
RewriteRule ^/(.+)\.html$ http://www.backend_server.com/handler.php?page=$1[b]&setcookie=true[/b]&lang=[b]EN[/b] [P]
Jim