2

I have two applications which used in pair and both used GMSGeocoder from GMSServices for reverseGeocodeCoordinate search. But in first one results are coming in english, on other - in device local language. Device is the same.

I searched a lot, and found that now is no ways to make GMSGeocoder use specified language for result. It is impossible and we should use google API requests instead. But it works somehow, and i have no idea how to make second application return results in english language only.

Similar concerns mapView - different languages on the same device.

How to set english for GMSServices regardless device localization?

Local device language present No local languge present

Dren
  • 2,017
  • 21
  • 18
  • 1
    I dont think you can change the language for `GMSGeocoder`, but you can try to change the language for your app: http://stackoverflow.com/a/24333593/4195406 – ztan Aug 10 '15 at 17:53
  • That the thing I was looking for. This code applied in fist application. Thank you a lot! You made my day. – Dren Aug 11 '15 at 08:51
  • Any side effects? – Billy Sep 08 '16 at 01:05
  • Ive used only english as app language, so didnt notice anything. (Cource, this dont means that them cant be there.) – Dren Sep 08 '16 at 07:17
  • I add an answer for this [Question](https://stackoverflow.com/questions/22908370/gmsgeocoder-how-to-set-response-language/51015794#51015794) . It can solve this issue perfectly. – Levi Han Jun 25 '18 at 03:17

3 Answers3

1

GMSGeocoder sent you the county name, but not the country ISO code.

You can use native CLGeocoder class to get counytyISOcode from latitude and longitude. For example:

CLLocation *location = (your location)
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:location completionHandler:
    ^(NSArray* placemarks, NSError* error){
        if ([placemarks count] > 0)
        {
            CLPlacemark *placemark = [placemarks objectAtIndex:0];
            NSLog(@"Your counry is %@",placemark. ISOcountryCode);
        }
}];
pablo.nunez
  • 124
  • 1
  • 5
0

Copy paste answer from stackoverflow.com/a/24333593/4195406

In - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

add

NSArray *languages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
    if (![[languages firstObject] isEqualToString:@"en"]) {
        [[NSUserDefaults standardUserDefaults] setObject:@[@"en"] forKey:@"AppleLanguages"];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }

This works for me

Community
  • 1
  • 1
Dren
  • 2,017
  • 21
  • 18
0

In Addition to @Dren answer - it will help to add regionCode as well in the array

NSArray *languages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
    if (![[languages firstObject] isEqualToString:@"he"]) {
        [[NSUserDefaults standardUserDefaults] setObject:@[@"he",@"he-IL"] forKey:@"AppleLanguages"];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
DaNLtR
  • 561
  • 5
  • 21