Answer the question
In order to leave comments, you need to log in
Properly organized language selection for the site
How to properly organize the choice of language for the user?
There is a site that is in Russian by default, but there is support for other languages. This is how mysite.com
opens by default . English version - mysite.com/en/
But what if an English-speaking person came? Now the Russian version of the site is being shown, and somewhere in the corner there is a language switcher.
Is there any common practice?
If you redirect somewhere immediately depending on the person’s language, then immediately the questions are how to determine the language (country ip vs setting in the browser), and how to redirect so that everything is ok with the search engines?
Answer the question
In order to leave comments, you need to log in
I think it’s more logical to check if the browser language, for example, is among the supported languages, then display it, if not, then English as international
We have this:
1. All language versions of the catalogs.
2. From the root redirect to the language version.
3. Determine the language by IP + Accept-Language.
4. If the user switches the language, it is stored in cookies. Next time, redirect from the root to the selected language.
There were no problems with the search engines.
Set the language based on the Accept-Language header from the client. If there is no language supported by the site, then the default language is displayed. This is for the first login. After the user himself has explicitly chosen the desired language, we write it in cookies and use it for repeated logins.
I think it's still better to make a pop-up, with a choice of language. And show it if the browser locale differs from the selected site language, and show it only once.
Based on IP
I don’t claim to be the author of the ideal code, I did this on one project: pastebin.com/9peMcj2y
In the geo folder (base from maxmind.com)
geoip.dat
geoip.inc
geoipregionvars.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question