updating func

This commit is contained in:
Kevin G Christiano 2021-03-17 13:52:20 -04:00
parent 63abf3d35e
commit e13530f5b4
2 changed files with 20 additions and 2 deletions

View File

@ -19,6 +19,12 @@
// Returns the hardcoded string from the string file.
+ (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key;
// Return current system language
+ (nullable NSString *)getSystemLanguage;
// Return current preferred system language
+ (nullable NSString *)getPreferredAvailableLanguage;
// Returns true if the user's language is Spanish
+ (BOOL)userPrefersSpanish;

View File

@ -18,15 +18,27 @@
return [NSBundle bundleWithIdentifier:@"com.vzw.MVMCore"];
}
// Confirms that the preferred user language is for spanish users.
+ (BOOL)userPrefersSpanish {
// Gets language code based on what the user prefers and the app provides.
NSString *languageCode = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];
NSString *languageCode = [MVMCoreGetterUtility getPreferredAvailableLanguage];
if (languageCode && [languageCode length] > 2) {
return [[[languageCode substringToIndex:2] lowercaseString] isEqualToString:@"es"];
} else {
return [[languageCode lowercaseString] isEqualToString:@"es"];
}
}
// Gets language code based on what the user prefers and the app provides.
+ (NSString *)getPreferredAvailableLanguage {
return [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];
}
+ (NSString *)getSystemLanguage {
return [[NSLocale preferredLanguages] objectAtIndex:0];
}
+ (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key {
// If the app language is not english... force load from the english file anyway.