Merge branch 'feature/improve_locale' into 'develop'
refactoring See merge request BPHV_MIPS/mvm_core_ui!691
This commit is contained in:
commit
7a8a28a121
@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
#pragma mark - Getters
|
#pragma mark - Getters
|
||||||
|
|
||||||
//Returns localized imageName
|
// Returns localized imageName
|
||||||
+ (nullable NSString *)localizedImageName:(nullable NSString *)imageName;
|
+ (nullable NSString *)localizedImageName:(nullable NSString *)imageName;
|
||||||
|
|
||||||
// The bundle for this framework
|
// The bundle for this framework
|
||||||
|
|||||||
@ -23,24 +23,14 @@
|
|||||||
return [NSBundle bundleWithIdentifier:@"com.vzw.MVMCoreUI"];
|
return [NSBundle bundleWithIdentifier:@"com.vzw.MVMCoreUI"];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (BOOL)userPrefersSpanish {
|
|
||||||
// This should be enough for us to look at what the user prefers.
|
|
||||||
NSString *preference = [[[[NSLocale preferredLanguages] objectAtIndex:0] substringToIndex:2] lowercaseString];
|
|
||||||
return [preference isEqualToString:@"es"] || [preference isEqualToString:@"es-mx"];
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key {
|
+ (nullable NSString *)hardcodedStringWithKey:(nonnull NSString *)key {
|
||||||
// If the app language is not english... force load from the english file anyway.
|
// Redirect key with relevant module.
|
||||||
if ([MVMCoreUIUtility userPrefersSpanish]) {
|
return [MVMCoreGetterUtility hardcodedStringWithKey:key bundle:[MVMCoreUIUtility bundleForMVMCoreUI]];
|
||||||
return [[NSBundle bundleWithPath:[[MVMCoreUIUtility bundleForMVMCoreUI] pathForResource:@"es" ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil];
|
|
||||||
} else {
|
|
||||||
return [[NSBundle bundleWithPath:[[MVMCoreUIUtility bundleForMVMCoreUI] pathForResource:@"en" ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (nullable NSString *)localizedImageName:(nullable NSString *)imageName {
|
+ (nullable NSString *)localizedImageName:(nullable NSString *)imageName {
|
||||||
if (imageName.length > 0) {
|
if (imageName.length > 0) {
|
||||||
if ([MVMCoreUIUtility userPrefersSpanish]) {
|
if ([MVMCoreGetterUtility userPrefersSpanish]) {
|
||||||
imageName = [NSString stringWithFormat:@"%@_es", imageName];
|
imageName = [NSString stringWithFormat:@"%@_es", imageName];
|
||||||
} else {
|
} else {
|
||||||
imageName = [NSString stringWithFormat:@"%@_en", imageName];
|
imageName = [NSString stringWithFormat:@"%@_en", imageName];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user