DEV Community

MondZigmond
MondZigmond

Posted on

Help: How to display my website according to country

Hello everyone.

Hope you are all well :)

I have a small simple website (Html, JS) that shows a Lucky Wheel.. when you spin it, each spin will display a nice Popup with a text.

Now, the text is in English.
I want to add to the same Popup message text but with the Hebrew language. (translate of the English one).
I want the following:

  • If someone will come from Israel - The message will be in Hebrew
  • If someone will come from the rest of the world - The message will be in English (translation will be extended with the time)

How can I implement that flow !?
Do I need to copy the page?
Coping the class?
Any other advice..

Your help would be much appreciated!

Thank you in advanced
:)

Top comments (2)

Collapse
 
iainfreestone profile image
Iain Freestone

You could look at window.navigator.language

The NavigatorLanguage.language read-only property returns a string representing the preferred language of the user, usually the language of the browser UI.

Link

Collapse
 
robbiegm profile image
RobbieGM

Don't use country to determine language--use the http accept-language header instead. That said, you can use the visitor's IP address to detect which country they're from.