i want to show the german name of the users city. Is it possible with the free Version of Maxmind Geoip? I did not find a way to open the GeoLite2-City.mmdb or GeoLiteCity.dat, to see which cities are listed, for building my own translation service. How can i open them?
相关问题
- How to properly change a resource dictionary
- How to transform IP addresses into geolocation in
- delphi translation tool [closed]
- Does Microsoft SQL Server support localized name s
- IOs7 multiple storyboard localization issue
相关文章
- xslt localization
- What is a satellite assembly?
- Get English exception message instead of local lan
- Google.Play web interface hl parameter for arabic
- non standard locale with java.util.Calendar
- Python csv writer wrong separator?
- Are there locales or common programs that use YYYY
- Get browser language in .AspNetCore2.0?
I would recommend using the PHP Extension API if you are concerned at all about performance. You can get upwards of 7 million queries per second with the PHP (C API) extension.
I describe how to compile the extension, and how to use the mmdb databases in PHP to get the localized city name here:
Intro to Maxmind GeoLite2 with Kohana PHP
Here's how to do it without Composer.
foo
.examples/benchmark.php
tofoo/benchmark.php
.src/MaxMind/Db
tofoo/Db
.foo/benchmark.php
.Change:
To:
You'll need PHP 5.3+. You even get some savings in code and number of files vs. using Composer. (Some testing code is eliminated, as well as the whole Guzzle structure.) Also, it makes it clearer how namespaces work in PHP as a nice replacement for classes (when classes are used just for name-spacing).
The rest of
benchmark.php
you can discard and start using$reader->get()
.If you do want to benchmark, on most platforms you need to modify the rand() call. Try this:
Change:
To:
Or just join four
mt_rand(0,255)
's with '.', which is probably easier!........................ Edit 2014/09 ........................
Added 'Db/Reader/Util.php' above.
Version of MaxMind-DB-Reader-php: 1.0.0 (2014-09-22)
Your file structure should look like this:
The GeoIP Legacy database does not include localized names, but the GeoIP2 (or GeoLite2) database does. You may access the localized name as follows:
Alternatively, if you would like the reader to default to German and fall back to English when it isn't available, you can set the language in the constructor: