From 3dc4ca55c19dacf06525026218916ac203a77926 Mon Sep 17 00:00:00 2001 From: Corentin <2089620+shajz@users.noreply.github.com> Date: Mon, 25 Mar 2024 11:27:10 +0100 Subject: [PATCH] fix(iOS): missing country translation --- src/ios/GoogleMaps/PluginGeocoder.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ios/GoogleMaps/PluginGeocoder.m b/src/ios/GoogleMaps/PluginGeocoder.m index 2ccfcaa28..86ae03085 100644 --- a/src/ios/GoogleMaps/PluginGeocoder.m +++ b/src/ios/GoogleMaps/PluginGeocoder.m @@ -29,7 +29,16 @@ - (void)pluginInitialize { NSString *identifier = [NSLocale localeIdentifierFromComponents: [NSDictionary dictionaryWithObject: countryCode forKey: NSLocaleCountryCode]]; NSString *country = [[[NSLocale alloc] initWithLocaleIdentifier:currentLanguage] displayNameForKey: NSLocaleIdentifier value: identifier]; - [countries addObject: country]; + if (country != nil) { + [countries addObject: country]; + } else { + NSString *countryFallback = [[[NSLocale alloc] initWithLocaleIdentifier:@"en-US"] displayNameForKey: NSLocaleIdentifier value: identifier]; + if (countryFallback != nil) { + [countries addObject: countryFallback]; + } else { + [countries addObject: countryCode]; + } + } } self.codeForCountryDictionary = [[NSDictionary alloc] initWithObjects:countryCodes forKeys:countries];