<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -82,6 +82,7 @@ module Geokit
     @@logger=Logger.new(STDOUT)
     @@logger.level=Logger::INFO
     @@domain = nil
+    @@lang = nil
     
     def self.__define_accessors
       class_variables.each do |v| 
@@ -130,8 +131,8 @@ module Geokit
       # Main method which calls the do_reverse_geocode template method which subclasses
       # are responsible for implementing.  Returns a populated GeoLoc or an
       # empty one with a failed success code.
-      def self.reverse_geocode(latlng)
-        res = do_reverse_geocode(latlng)
+      def self.reverse_geocode(latlng, options = {})
+        res = do_reverse_geocode(latlng, options)
         return res.success? ? res : GeoLoc.new        
       end
       
@@ -146,7 +147,7 @@ module Geokit
       # Not all geocoders can do reverse geocoding. So, unless the subclass explicitly overrides this method,
       # a call to reverse_geocode will return an empty GeoLoc. If you happen to be using MultiGeocoder,
       # this will cause it to failover to the next geocoder, which will hopefully be one which supports reverse geocoding.
-      def self.do_reverse_geocode(latlng)
+      def self.do_reverse_geocode(latlng, options = {})
         return GeoLoc.new
       end
 
@@ -392,9 +393,19 @@ module Geokit
       private 
       
       # Template method which does the reverse-geocode lookup.
-      def self.do_reverse_geocode(latlng) 
+      #
+      # ==== OPTIONS
+      # * :lang - This option makes the Google Geocoder return localized results.
+      #           Just give a country code and hope Google supports it ;-)
+      #           Defaults to 'en'.
+      #
+      # ==== EXAMPLE
+      # # Get German locality names
+      # Geokit::Geocoders::GoogleGeocoder.reverse_geocode('51.0, 9.0', :lang =&gt; :de)
+      def self.do_reverse_geocode(latlng, options = {})
         latlng=LatLng.normalize(latlng)
-        res = self.call_geocoder_service(&quot;http://maps.google.com/maps/geo?ll=#{Geokit::Inflector::url_escape(latlng.ll)}&amp;output=xml&amp;key=#{Geokit::Geocoders::google}&amp;oe=utf-8&quot;)
+        lang = options[:lang] || Geokit::Geocoders::lang || 'en'
+        res = self.call_geocoder_service(&quot;http://maps.google.com/maps/geo?ll=#{Geokit::Inflector::url_escape(latlng.ll)}&amp;output=xml&amp;key=#{Geokit::Geocoders::google}&amp;oe=utf-8&amp;hl=#{lang.to_s.downcase}&quot;)
         #        res = Net::HTTP.get_response(URI.parse(&quot;http://maps.google.com/maps/geo?ll=#{Geokit::Inflector::url_escape(address_str)}&amp;output=xml&amp;key=#{Geokit::Geocoders::google}&amp;oe=utf-8&quot;))
         return GeoLoc.new unless (res.is_a?(Net::HTTPSuccess) || res.is_a?(Net::HTTPOK))
         xml = res.body
@@ -667,11 +678,11 @@ module Geokit
       # This method will call one or more geocoders in the order specified in the 
       # configuration until one of the geocoders work, only this time it's going
       # to try to reverse geocode a geographical point.
-      def self.do_reverse_geocode(latlng)
+      def self.do_reverse_geocode(latlng, options = {})
         Geokit::Geocoders::provider_order.each do |provider|
           begin
             klass = Geokit::Geocoders.const_get &quot;#{Geokit::Inflector::camelize(provider.to_s)}Geocoder&quot;
-            res = klass.send :reverse_geocode, latlng
+            res = klass.send :reverse_geocode, latlng, options
             return res if res.success?
           rescue
             logger.error(&quot;Something has gone very wrong during reverse geocoding, OR you have configured an invalid class name in Geokit::Geocoders::provider_order. LatLng: #{latlng}. Provider: #{provider}&quot;)</diff>
      <filename>lib/geokit/geocoders.rb</filename>
    </modified>
    <modified>
      <diff>@@ -167,7 +167,7 @@ class GoogleGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
     madrid.lat, madrid.lng = &quot;40.4167413&quot;, &quot;-3.7032498&quot;
     response = MockSuccess.new
     response.expects(:body).returns(GOOGLE_REVERSE_MADRID)
-    url = &quot;http://maps.google.com/maps/geo?ll=#{Geokit::Inflector::url_escape(madrid.ll)}&amp;output=xml&amp;key=#{Geokit::Geocoders::google}&amp;oe=utf-8&quot;
+    url = &quot;http://maps.google.com/maps/geo?ll=#{Geokit::Inflector::url_escape(madrid.ll)}&amp;output=xml&amp;key=#{Geokit::Geocoders::google}&amp;oe=utf-8&amp;hl=en&quot;
     Geokit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).
       returns(response)
     res=Geokit::Geocoders::GoogleGeocoder.do_reverse_geocode(madrid.ll)</diff>
      <filename>test/test_google_geocoder.rb</filename>
    </modified>
    <modified>
      <diff>@@ -33,7 +33,7 @@ class GoogleReverseGeocoderTest &lt; BaseGeocoderTest #:nodoc: all
     
     @latlng = &quot;51.4578329,7.0166848&quot;
     
-    url = &quot;http://maps.google.com/maps/geo?ll=#{Geokit::Inflector.url_escape(@latlng)}&amp;output=xml&amp;key=Google&amp;oe=utf-8&quot;
+    url = &quot;http://maps.google.com/maps/geo?ll=#{Geokit::Inflector.url_escape(@latlng)}&amp;output=xml&amp;key=Google&amp;oe=utf-8&amp;hl=en&quot;
     Geokit::Geocoders::GoogleGeocoder.expects(:call_geocoder_service).with(url).returns(response)
     res=Geokit::Geocoders::GoogleGeocoder.reverse_geocode(@latlng) 
     assert_equal &quot;Nordrhein-Westfalen&quot;, res.state</diff>
      <filename>test/test_google_reverse_geocoder.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b67a04600aad96e1c21965de2619105d012f6dd4</id>
    </parent>
  </parents>
  <author>
    <name>Torsten Sch&#246;nebaum</name>
    <email>torsten.schoenebaum@planquadrat-software.de</email>
  </author>
  <url>http://github.com/tosch/geokit-gem/commit/9a7232d7d56059558107129ab3bcf51bcb67d45b</url>
  <id>9a7232d7d56059558107129ab3bcf51bcb67d45b</id>
  <committed-date>2009-09-29T09:06:22-07:00</committed-date>
  <authored-date>2009-09-29T09:06:22-07:00</authored-date>
  <message>enable localized responses when reverse geocoding with the Google geocoder</message>
  <tree>c246529738fe1f91af8a8ab02a66bed2741feb0b</tree>
  <committer>
    <name>Torsten Sch&#246;nebaum</name>
    <email>torsten.schoenebaum@planquadrat-software.de</email>
  </committer>
</commit>
