0

I´m developing a webpage and it has some entries in which it would be interesting to force my web server to show an html file not only autotranslated (mainly between english and spanish) but also to load the specific social media links which are created in those languages (as there is an English Instagram version and another Spanish one, an English Twitter account and another for Spanish, and so on), depending on the physical location of the webpage users.

Thanks in advance.

  • Readers who prefer language X don't all live in region Y so a language setting on your page is probably better than trying to detect location and then force a language. Or look at the browser language setting: https://stackoverflow.com/questions/673905/how-to-determine-users-locale-within-browser – Dave S May 20 '22 at 20:51
  • @DaveS it may be a possibility, but you mean to include a language toggler or something like this? – Diego Manzanares May 20 '22 at 21:22
  • You can do either or both: detect the browser language setting with JavaScript, offer a language setting toggle. or use the browser as the initial setting then let users force a different language using the toggle for people with their browser language set to (A) who still want to read your site using language (B). – Dave S May 20 '22 at 21:55

1 Answers1

0

In principle you could detect the location. But I am guessing that what you really want is to detect the language of the user. For this there are multiple ways, see e.g.: JavaScript for detecting browser language preference

Falk Tandetzky
  • 5,226
  • 2
  • 15
  • 27
  • I think I will stick with the language toggler by now. I have configured one on the webpage and it seems to work only locally, but not when it is uploaded to the web server. This is the toggler I´m using: https://codepen.io/TorabRamin/pen/mqrBBj As I mentioned it works locally but not when uploaded to the server, as it appears as a kind of html form when you can check any of the languages, but not in a toggle form. – Diego Manzanares May 20 '22 at 22:09