Skip to content

Commit

Permalink
[localization] Fix exporting region constant (#5740)
Browse files Browse the repository at this point in the history
# Why

Resolve #5735.

# How

Wrapped `region` variable into UMNullIfNil macro, because `[[NSLocale currentLocale] objectForKey:NSLocaleCountryCode]` could return nil on iOS simulator.
  • Loading branch information
lukmccall authored and tsapeta committed Oct 15, 2019
1 parent bcc947e commit d3584d7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/expo-localization/ios/EXLocalization/EXLocalization.m
Expand Up @@ -21,6 +21,14 @@ @implementation EXLocalization
- (NSDictionary *)constantsToExport
{
NSArray<NSString *> *preferredLocales = [NSLocale preferredLanguages];
if (preferredLocales == nil) {
NSString *currentLocale = [[NSLocale currentLocale] localeIdentifier];
if (currentLocale == nil) {
currentLocale = @"en_US";
}
preferredLocales = @[currentLocale];
}

NSTimeZone *currentTimeZone = [NSTimeZone localTimeZone];
NSString *region = [[NSLocale currentLocale] objectForKey:NSLocaleCountryCode];

Expand All @@ -30,7 +38,7 @@ - (NSDictionary *)constantsToExport
@"locales": preferredLocales,
@"timezone": [currentTimeZone name],
@"isoCurrencyCodes": [NSLocale ISOCurrencyCodes],
@"region": region
@"region": UMNullIfNil(region)
};
}

Expand Down

0 comments on commit d3584d7

Please sign in to comment.