1
I wonder if there is a php or JS function that through the visitor’s IP makes it possible to translate the site automatically according to the country of the internet user without needing him to choose the language manually in a select.
Suppose my website were visited by someone from England, then automatically the script would choose the English language from the Lang folder. If visited by someone from Italy automatically the script would run the Italian language, for visitors from Portugal and Brazil would run the Portuguese language and so on.
I looked for something of the kind but found nothing on the subject.
I noticed that in Adsense ads, google uses this function, because even if we Brazilians visit a foreign site, the ads that Adsense displays are from Brazilian campaigns. It’s as if it detected the visitor’s location. And that’s what I want, to detect the user’s parents and create a condition like:
Se localidade do visitante é igual à Brasil ou Portugal
Utilizar idioma português
Se não se localidade do visitante é igual à EUA ou Inglaterra ou Canadá etc
Utilizar idioma inglês
Se não se localidade do visitante é igual à Espanha ou Argentina ou México etc
Utilizar idioma espanhol
e assim por diante ...
Can use
navigator.language
to take the language used in the user’s browser and then call a resource on the server that returns the phrases/words in that language.– Renan Gomes
Related: Detect browser language and redirect, How to make a multilingual site? and How to translate a website into PHP?. You have other questions on the subject, you can search for the term i18n.
– rray