Permalink
Browse files

Added language parameter

  • Loading branch information...
1 parent 6bbe549 commit 437d5f536e06aebf21f2184654117b3afd266961 @iskachkov iskachkov committed Jun 27, 2012
Showing with 9 additions and 1 deletion.
  1. +4 −1 googlegeocoder/__init__.py
  2. +5 −0 tests.py
@@ -23,7 +23,8 @@ def _fetch_json(self, params):
response = urllib2.urlopen(request)
return json.loads(response.read())
- def get(self, submission, sensor='false', bounding_box=None, region=None):
+ def get(self, submission, sensor='false', bounding_box=None, region=None,
+ language=None):
params = {'sensor': sensor}
if isinstance(submission, basestring):
params['address'] = submission
@@ -41,6 +42,8 @@ def get(self, submission, sensor='false', bounding_box=None, region=None):
)
if region:
params['region'] = region
+ if language:
+ params['language'] = language
data = self._fetch_json(params)
if data["status"] != "OK":
raise ValueError(data["status"])
View
5 tests.py 100644 → 100755
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+# -*- coding: utf-8 -*-
import unittest
from googlegeocoder import *
from pprint import pprint
@@ -45,6 +46,10 @@ def test_region_bias(self):
result = self.geocoder.get("Toledo", region='ES')
self.assertEqual(result[0].formatted_address, u'Toledo, Spain')
+ def test_language(self):
+ result = self.geocoder.get('Moscow', language='ru')
+ self.assertEqual(result[0].formatted_address, u'Москва, Россия')
+
if __name__ == '__main__':
unittest.main()

0 comments on commit 437d5f5

Please sign in to comment.