Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale fallback #16

Open
svoop opened this issue Nov 9, 2014 · 1 comment
Open

Locale fallback #16

svoop opened this issue Nov 9, 2014 · 1 comment

Comments

@svoop
Copy link

svoop commented Nov 9, 2014

The paid GeoIP city database from Maxmind often doesn't hold translations for cities. The IP address 88.162.113.13 is located in Les Angles, France. Here are the lookup results:

GeoIP2::locate '88.162.113.13', 'fr'
=> {"city"=>nil,
 "city_geoname_id"=>3002160,
 "country"=>"France",
 "country_geoname_id"=>3017382,
 "country_code"=>"FR",
 "continent"=>"Europe",
 "continent_code"=>"EU",
 "continent_geoname_id"=>6255148,
 "subdivision"=>"Région Languedoc-Roussillon",
 "subdivision_code"=>"K",
 "subdivision_geoname_id"=>3007670,
 "postal_code"=>"30133",
 "latitude"=>42.5788,
 "longitude"=>2.0739,
 "time_zone"=>"Europe/Paris"}

GeoIP2::locate '88.162.113.13', 'en'
=> {"city"=>"Les Angles",
 "city_geoname_id"=>3002160,
 "country"=>"France",
 "country_geoname_id"=>3017382,
 "country_code"=>"FR",
 "continent"=>"Europe",
 "continent_code"=>"EU",
 "continent_geoname_id"=>6255148,
 "subdivision"=>"Languedoc-Roussillon",
 "subdivision_code"=>"K",
 "subdivision_geoname_id"=>3007670,
 "postal_code"=>"30133",
 "latitude"=>42.5788,
 "longitude"=>2.0739,
 "time_zone"=>"Europe/Paris"}

As you see, no city name is returned when a French city is queried with locale "fr", however, it is returned with locale "en". The consumer of your gem can only deal with this situation by performing a second lookup. Not so good!

Would it be possible to add a fallback setting such as:

GeoIP2::fallback_locale 'en'

If set, a lookup which finds a city (city_geoname_id is present) but no city name in the queried locale returns the city name in the fallback locale.

@svoop
Copy link
Author

svoop commented Nov 9, 2014

(I usually code and submit pull requests myself, but unfortunately I'm not much of a C programmer.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant