providing redirect

This commit is contained in:
Kevin G Christiano 2021-03-18 11:46:07 -04:00
parent e13530f5b4
commit 7581c6609f
2 changed files with 12 additions and 6 deletions

View File

@ -19,6 +19,9 @@
// Returns the hardcoded string from the string file.
+ (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key;
// Returns the hardcoded string from the string file based on module.
+ (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key bundle:(nullable NSBundle *)bundle;
// Return current system language
+ (nullable NSString *)getSystemLanguage;

View File

@ -35,19 +35,22 @@
return [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];
}
// Returns the preferred language set system wide.
+ (NSString *)getSystemLanguage {
return [[NSLocale preferredLanguages] objectAtIndex:0];
}
+ (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key {
// Redirect key with relevant module.
return [MVMCoreGetterUtility hardcodedStringWithKey:key bundle:[MVMCoreGetterUtility bundleForMVMCore]];
}
+ (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key bundle:(nullable NSBundle *)bundle {
// If the app language is not english... force load from the english file anyway.
if ([MVMCoreGetterUtility userPrefersSpanish]) {
return [[NSBundle bundleWithPath:[[MVMCoreGetterUtility bundleForMVMCore] pathForResource:@"es" ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil];
} else {
return [[NSBundle bundleWithPath:[[MVMCoreGetterUtility bundleForMVMCore] pathForResource:@"en" ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil];
}
NSString *languageCode = [MVMCoreGetterUtility userPrefersSpanish] ? @"es" : @"en";
return [[NSBundle bundleWithPath:[bundle pathForResource:languageCode ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil];
}
+ (nonnull UIColor *)getColorForHexString:(nonnull NSString *)hexString {