improve locae check behavior

This commit is contained in:
Kevin G Christiano 2021-03-17 11:37:01 -04:00
parent 1d2e878aa9
commit 86819283c0
2 changed files with 7 additions and 3 deletions

View File

@ -7,7 +7,6 @@
// Copyright © 2019 myverizon. All rights reserved.
//
import Foundation
public struct ModelRegistry {

View File

@ -19,8 +19,13 @@
}
+ (BOOL)userPrefersSpanish {
// This should be enough for us to look at what the user prefers.
return [[[[[NSLocale preferredLanguages] objectAtIndex:0] substringToIndex:2] lowercaseString] isEqualToString:@"es"];
// Gets preferences based on what the user wants and the app provides.
NSString *languageCode = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];
if (languageCode && [languageCode length] > 2) {
return [[[languageCode substringToIndex:2] lowercaseString] isEqualToString:@"es"];
} else {
return [[languageCode lowercaseString] isEqualToString:@"es"];
}
}
+ (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key {