Skip to content

Commit

Permalink
Merge pull request ResearchKit#43 from Erin-Mounts/i18n
Browse files Browse the repository at this point in the history
Internationalization
  • Loading branch information
Erin-Mounts committed Nov 20, 2015
2 parents 4c4318d + a9ddc52 commit d6369b3
Show file tree
Hide file tree
Showing 108 changed files with 2,045 additions and 664 deletions.
195 changes: 175 additions & 20 deletions APCAppCore/APCAppCore.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions APCAppCore/APCAppCore/APCAppCore.h
Expand Up @@ -45,6 +45,7 @@ FOUNDATION_EXPORT const unsigned char APCAppCoreVersionString[];
/* -------------------------------------
Headers
--------------------------------------- */
#import <APCAppCore/APCLocalization.h>
#import <APCAppCore/APCCMSSupport.h>
#import <APCAppCore/APCConstants.h>
#import <APCAppCore/APCAppDelegate.h>
Expand Down
7 changes: 4 additions & 3 deletions APCAppCore/APCAppCore/Consent/APCConsentTask.m
Expand Up @@ -33,6 +33,7 @@

#import "APCConsentTask.h"
#import "APCLog.h"
#import "APCLocalization.h"
#import "APCConsentQuestion.h"
#import "APCConsentBooleanQuestion.h"
#import "APCConsentInstructionQuestion.h"
Expand Down Expand Up @@ -174,9 +175,9 @@ - (NSArray*)commonInitWithPropertiesFileName:(NSString*)fileName customSteps:(NS
identifier:@"participant"];
ORKConsentDocument* document = [[ORKConsentDocument alloc] init];

document.title = NSLocalizedString(@"Consent", nil);
document.signaturePageTitle = NSLocalizedString(@"Consent", nil);
document.signaturePageContent = NSLocalizedString(@"By agreeing you confirm that you read the consent and that you wish to take part in this research study.", nil);
document.title = APCLocalizedString(@"Consent", nil);
document.signaturePageTitle = APCLocalizedString(@"Consent", nil);
document.signaturePageContent = APCLocalizedString(@"By agreeing you confirm that you read the consent and that you wish to take part in this research study.", nil);
document.sections = self.documentSections;
document.htmlReviewContent = self.documentHtmlContent;

Expand Down
Expand Up @@ -572,7 +572,7 @@ - (ORKAnswerFormat*) rkChoiceAnswerFormat:(NSDictionary *)objectDictionary
[options addObject: choice];
}];
if (localConstraints.allowOtherValue) {
[options addObject:NSLocalizedString(@"Other", @"Spinner Option")];
[options addObject:APCLocalizedString(@"Other", @"Spinner Option")];
}
retAnswer = [ORKAnswerFormat choiceAnswerFormatWithStyle:localConstraints.allowMultipleValue ? ORKChoiceAnswerStyleMultipleChoice : ORKChoiceAnswerStyleSingleChoice textChoices:options];
return retAnswer;
Expand Down
2 changes: 1 addition & 1 deletion APCAppCore/APCAppCore/DataSubstrate/Model/APCUser+Bridge.m
Expand Up @@ -541,6 +541,6 @@ - (NSString *)passwordForAuthManager:(id<SBBAuthManagerProtocol>) __unused authM

- (NSString *)noInternetString
{
return NSLocalizedString(@"No network connection. Please connect to the internet and try again.", @"No Internet");
return APCLocalizedString(@"No network connection. Please connect to the internet and try again.", @"No Internet");
}
@end
7 changes: 4 additions & 3 deletions APCAppCore/APCAppCore/DataSubstrate/Model/APCUser+UserData.m
Expand Up @@ -32,23 +32,24 @@
//

#import "APCUser+UserData.h"
#import "APCLocalization.h"

@implementation APCUser (UserData)

/***************
Biologial Sex
****************/
+ (NSArray *) sexTypesInStringValue {
return @[ NSLocalizedString(@"Male", @""), NSLocalizedString(@"Female", @"")];
return @[ APCLocalizedString(@"Male", @""), APCLocalizedString(@"Female", @"")];
}

+ (HKBiologicalSex) sexTypeFromStringValue:(NSString *)stringValue {
HKBiologicalSex sexType;

if ([stringValue isEqualToString:NSLocalizedString(@"Male", @"")]) {
if ([stringValue isEqualToString:APCLocalizedString(@"Male", @"")]) {
sexType = HKBiologicalSexMale;
}
else if ([stringValue isEqualToString:NSLocalizedString(@"Female", @"")]) {
else if ([stringValue isEqualToString:APCLocalizedString(@"Female", @"")]) {
sexType = HKBiologicalSexFemale;
}
else {
Expand Down
33 changes: 33 additions & 0 deletions APCAppCore/APCAppCore/Library/APCLocalization.m
@@ -0,0 +1,33 @@
//
// APCLocalization.m
// APCAppCore
//
// Created by Erin Mounts on 11/18/15.
// Copyright © 2015 Apple, Inc. All rights reserved.
//

#import "APCLocalization.h"
#import "APCUser.h"

NSBundle *APCBundle() {
static NSBundle *__bundle;

static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
__bundle = [NSBundle bundleForClass:[APCUser class]];
});

return __bundle;
}

NSBundle *APCDefaultLocaleBundle() {
static NSBundle *__bundle;

static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSString *path = [APCBundle() pathForResource:[APCBundle() objectForInfoDictionaryKey:@"CFBundleDevelopmentRegion"] ofType:@"lproj"];
__bundle = [NSBundle bundleWithPath:path];
});

return __bundle;
}
Expand Up @@ -32,6 +32,7 @@
//

#import "APCAssertionHandler.h"
#import "APCLocalization.h"

@import UIKit;

Expand All @@ -55,11 +56,11 @@ - (void) handleFailureInFunction: (NSString *) __unused functionName
}

- (void) exitGracefully {
NSString *alertTitle = NSLocalizedString(@"Somthings Wrong!", @"");
NSString *alertTitle = APCLocalizedString(@"Somethings Wrong!", @"");

NSString *alertMessage = NSLocalizedString(@"Oops! Something went wrong. We are really sorry for the inconvenience. Since we are not taking any risk on your data, you may need to restart the app.", @"");
NSString *alertMessage = APCLocalizedString(@"Oops! Something went wrong. We are really sorry for the inconvenience. Since we are not taking any risk on your data, you may need to restart the app.", @"");

UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Okay", @"") style:UIAlertActionStyleCancel handler:^(UIAlertAction * __unused action) {
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:APCLocalizedString(@"Okay", @"") style:UIAlertActionStyleCancel handler:^(UIAlertAction * __unused action) {
exit(0);
}];

Expand Down
5 changes: 3 additions & 2 deletions APCAppCore/APCAppCore/Library/Categories/NSDate+Helper.m
Expand Up @@ -34,6 +34,7 @@
#import "NSDate+Helper.h"
#import "APCConstants.h"
#import "NSDateComponents+Helper.h"
#import "APCLocalization.h"


NSString * const NSDateDefaultDateFormat = @"MMM dd, yyyy";
Expand Down Expand Up @@ -146,11 +147,11 @@ -(NSString *) friendlyDescription
NSString * retValue;
if([date isEqual:today])
{
retValue = NSLocalizedString(@"Today", nil);
retValue = APCLocalizedString(@"Today", nil);
}
else if([date isEqual:yesterday])
{
retValue = NSLocalizedString(@"Yesterday", nil);
retValue = APCLocalizedString(@"Yesterday", nil);
}
else if(([date laterDate:oneWeekAgo] == date) && ([date laterDate:tomorrow] == tomorrow))
{
Expand Down
13 changes: 7 additions & 6 deletions APCAppCore/APCAppCore/Library/Categories/NSError+APCAdditions.m
Expand Up @@ -33,6 +33,7 @@

#import "NSError+APCAdditions.h"
#import "APCLog.h"
#import "APCLocalization.h"

NSString * const kAPCServerBusyErrorMessage = @"Thank you for your interest in this study. We are working hard to process the large volume of interest, and should be back up momentarily. Please try again soon.";
NSString * const kAPCUnexpectedConditionErrorMessage = @"An unexpected network condition has occurred. Please try again soon.";
Expand All @@ -56,7 +57,7 @@ - (NSString*)checkMessageForNonUserTerms:(NSString*)message
[message containsString:@"NSURLError"] ||
[message rangeOfString:@"contact somebody" options:NSCaseInsensitiveSearch].location != NSNotFound)
{
return NSLocalizedString(@"An unknown error occurred", nil);
return APCLocalizedString(@"An unknown error occurred", nil);
}
return message;
}
Expand All @@ -78,19 +79,19 @@ - (NSString *)networkErrorMessage
NSString *message;

if (self.code == 409) {
message = NSLocalizedString(kAPCAccountAlreadyExistsErrorMessage, nil);
message = APCLocalizedString(kAPCAccountAlreadyExistsErrorMessage, nil);
}
else if (self.code == 404) {
message = NSLocalizedString(kAPCAccountDoesNotExistErrorMessage, nil);
message = APCLocalizedString(kAPCAccountDoesNotExistErrorMessage, nil);
}
else if (self.code >= 500 && self.code < 600) {
message = NSLocalizedString(kAPCServerBusyErrorMessage, nil);
message = APCLocalizedString(kAPCServerBusyErrorMessage, nil);
}
else if (self.code == kCFURLErrorDNSLookupFailed || self.code == kCFURLErrorInternationalRoamingOff) {
message = NSLocalizedString(kAPCNotConnectedErrorMessage, nil);
message = APCLocalizedString(kAPCNotConnectedErrorMessage, nil);
}
else {
message = NSLocalizedString(kAPCUnexpectedConditionErrorMessage, nil);
message = APCLocalizedString(kAPCUnexpectedConditionErrorMessage, nil);
}

return message;
Expand Down
23 changes: 12 additions & 11 deletions APCAppCore/APCAppCore/Library/Categories/NSError+Bridge.m
Expand Up @@ -35,6 +35,7 @@
#import "APCLog.h"
#import <BridgeSDK/BridgeSDK.h>
#import "APCLog.h"
#import "APCLocalization.h"

static NSString *kSageMessageKey = @"message";
static NSString *kSageErrorsKey = @"errors";
Expand All @@ -61,7 +62,7 @@ - (NSString*)bridgeErrorMessage

if (e.code == kCFURLErrorNotConnectedToInternet)
{
message = NSLocalizedString(kAPCNotConnectedErrorMessage, nil);
message = APCLocalizedString(kAPCNotConnectedErrorMessage, nil);
}
else
{
Expand All @@ -75,44 +76,44 @@ - (NSString*)bridgeErrorMessage
NSDictionary * errors = [code valueForKey: kSageErrorsKey];
if([errors valueForKey: kSageErrorEmailKey])
{
message = NSLocalizedString(kAPCBadEmailAddressErrorMessage, nil);
message = APCLocalizedString(kAPCBadEmailAddressErrorMessage, nil);
}
else if([errors valueForKey: kSageErrorPasswordKey])
{
message = NSLocalizedString(kAPCBadPasswordErrorMessage, nil);
message = APCLocalizedString(kAPCBadPasswordErrorMessage, nil);
} else
{
message = NSLocalizedString(kAPCInvalidEmailAddressOrPasswordErrorMessage, nil);
message = APCLocalizedString(kAPCInvalidEmailAddressOrPasswordErrorMessage, nil);
}

}
else if (self.code == 409)
{
message = NSLocalizedString(kAPCAccountAlreadyExistsErrorMessage, nil);
message = APCLocalizedString(kAPCAccountAlreadyExistsErrorMessage, nil);
}
else if (self.code == 404)
{
message = NSLocalizedString(kAPCAccountDoesNotExistErrorMessage, nil);
message = APCLocalizedString(kAPCAccountDoesNotExistErrorMessage, nil);
}
else if ([code isEqual:@(503)] || self.code == 503)
{
message = NSLocalizedString(kAPCServerBusyErrorMessage, nil);
message = APCLocalizedString(kAPCServerBusyErrorMessage, nil);
}
else if ([code isEqual: @(kSBBInternetNotConnected)])
{
message = NSLocalizedString(kAPCNotConnectedErrorMessage, nil);
message = APCLocalizedString(kAPCNotConnectedErrorMessage, nil);
}
else if ([code isEqual:@(kSBBServerNotReachable)])
{
message = NSLocalizedString(kAPCNotReachableErrorMessage, nil);
message = APCLocalizedString(kAPCNotReachableErrorMessage, nil);
}
else if ([code isEqual:@(kSBBServerUnderMaintenance)])
{
message = NSLocalizedString(kAPCServerUnderMaintanenceErrorMessage, nil);
message = APCLocalizedString(kAPCServerUnderMaintanenceErrorMessage, nil);
}
else
{
message = NSLocalizedString(kAPCUnexpectedConditionErrorMessage, nil);
message = APCLocalizedString(kAPCUnexpectedConditionErrorMessage, nil);
}

return message;
Expand Down
Expand Up @@ -93,7 +93,7 @@ - (NSArray*)locationArrayWithLocationManager:(CLLocationManager*)manager
}
else
{
speed = NSLocalizedString(@"invalid speed", nil);
speed = APCLocalizedString(@"invalid speed", nil);
}

NSString* speedUnit = @"meters/second"; //Not a user facing constant
Expand All @@ -102,7 +102,7 @@ - (NSArray*)locationArrayWithLocationManager:(CLLocationManager*)manager
// A nil value of manager.location.floor indicates that this info is unavailable.
if (manager.location.floor == nil)
{
floor = NSLocalizedString(@"not available", nil);
floor = APCLocalizedString(@"not available", nil);
}
else
{
Expand Down
Expand Up @@ -32,14 +32,15 @@
//

#import "UIAlertController+Helper.h"
#import "APCLocalization.h"

@implementation UIAlertController (Helper)

+ (UIAlertController *) simpleAlertWithTitle:(NSString *)title message:(NSString *)message
{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *okayAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"") style:UIAlertActionStyleDefault handler:nil];
UIAlertAction *okayAction = [UIAlertAction actionWithTitle:APCLocalizedString(@"OK", @"") style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:okayAction];

return alertController;
Expand Down

0 comments on commit d6369b3

Please sign in to comment.