From 7581c6609f2043f458f10ec1932fd53a047e13fb Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 18 Mar 2021 11:46:07 -0400 Subject: [PATCH] providing redirect --- .../Utility/Helpers/MVMCoreGetterUtility.h | 3 +++ .../Utility/Helpers/MVMCoreGetterUtility.m | 15 +++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.h b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.h index df18405..64feae8 100644 --- a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.h +++ b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.h @@ -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; diff --git a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m index 0d2f8ef..a132316 100644 --- a/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m +++ b/MVMCore/MVMCore/Utility/Helpers/MVMCoreGetterUtility.m @@ -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 {