Stony has a great response to doing this via php, and I'd very much recommend that if that's your backend. But, you can also do this on the client with javascript several ways.

First is to get the user's coordinates via the browser using javascript. To do this, though, your users will have to allow you to view their location. You can do this pretty simply:

let userLocationData = {}; if ("geolocation" in navigator) { navigator.geolocation.getCurrentPosition(function(position){ userLocationData.lat = position.coords.latitude; userLocationData.long = position.coords.longitude; }) }

Of course, this is just the lat/long. You'll then need to use some api to get better data from that. I use GeoNames. Now again, this depends on if you're doing this on the client or server, but I'll give you an example with Meteor's HTTP service, though you could do this with ajax or express or anything.

let locationResults = HTTP.call('GET',`http://api.geonames.org/findNearbyPostalCodesJSON?formatted=true&lat=${userLocationData.lat}&lng=${userLocationData.long}&username=YOURUSERNAMEHERE`;

This will return an array of objects. So you could just do something like this:

userLocationData.country = locationResults[0].countryCode;

You can visit this url to see what that data might look like. http://api.geonames.org/findNearbyPostalCodesJSON?formatted=true&lat=40.987148&lng=-90.0803689&username=thatgibbyguy

Now, you have their location and country. But can you tell language from that? I'd say no. You should probably just check for their language:

userLocationData.language = navigator.language;

That's going to use the user's own settings for language that you can use immediately. From there you reroute pretty easily: