4 ms·
Made this on my spare time over a couple of weekends. In my past projects (both for work and hobbies), most of the time when I needed a GeoIP search, it was alw
by godot 9y ago
Made this on my spare time over a couple of weekends. In my past projects (both for work and hobbies), most of the time when I needed a GeoIP search, it was always for one of the following reasons: getting the user's country to determine if US or non-US (geo lock in some way), getting a default currency to use, getting a default language to use, or timezone of the user.
I figured I'd put this all together in one API service, to make that possible 2-3 steps of things to do in code to be just 1 step.
- stephenr 9y ago> getting a default language to use Please don't use geoip for language detection. Geographic location has literally nothing to do with the language the user understands. There is a http header dedicated to client language preferences. Please use it.
- godot 9y agoLiterally first question on the FAQ section if you just scrolled down a little bit on the page :) >1. How accurate is the language data? > > We determine language purely based on what country the user resides in, based on their IP address. Like any human being, your user could live in (or stay in) a certain country and speak a different language than the official language of the country. For best results, you should also check the Accept-Language HTTP header of your user's client, and determine what to use in your web app. > > Similarly, Android apps could use the Locale.getDefault().getISO3Language() call and iOS apps could use the NSLocale.preferredLanguages()[0] as String call to get user languages.
- stephenr 9y agoWhy make it available at all though. You may as well provide a field saying "gender: male" because 51% of the population of the country this users ip is located in, are male and we rounded up. If companies like google can massively fuck up language selection based on ip, you can guarantee other devs will too, if you give them the data.
- godot 9y agoThere is still a variety of valid use cases and design though, no? Say your site offers English, Chinese, Japanese, and a number of other languages. Your user's HTTP header says they can accept Japanese. So you default to Japanese. Their IP says they're in China. Wouldn't you want Chinese to be the 2nd choice on the language list to choose from, because that's a more likely choice for the user (if they were to have to switch) rather than English, French, Spanish, etc.? I'm sure it doesn't take a lot of imagination to think of a lot of other use cases. At the end of the day, it just gives you one more data point to act on. ;)