Skip to content

Commit

Permalink
Merge pull request ResearchKit#45 from Erin-Mounts/i18n
Browse files Browse the repository at this point in the history
More internationalization stuff
  • Loading branch information
Erin-Mounts committed Nov 21, 2015
2 parents 383d678 + a63b6e0 commit 8a01597
Show file tree
Hide file tree
Showing 66 changed files with 451 additions and 512 deletions.
181 changes: 46 additions & 135 deletions APCAppCore/APCAppCore.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions APCAppCore/APCAppCore/Consent/APCConsentTask.m
Expand Up @@ -175,9 +175,9 @@ - (NSArray*)commonInitWithPropertiesFileName:(NSString*)fileName customSteps:(NS
identifier:@"participant"];
ORKConsentDocument* document = [[ORKConsentDocument alloc] init];

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.title = NSLocalizedStringWithDefaultValue(@"Consent", @"APCAppCore", APCBundle(), @"Consent", nil);
document.signaturePageTitle = NSLocalizedStringWithDefaultValue(@"Consent", @"APCAppCore", APCBundle(), @"Consent", nil);
document.signaturePageContent = NSLocalizedStringWithDefaultValue(@"By agreeing you confirm that you read the consent and that you wish to take part in this research study.", @"APCAppCore", APCBundle(), @"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:APCLocalizedString(@"Other", @"Spinner Option")];
[options addObject:NSLocalizedStringWithDefaultValue(@"Other", @"APCAppCore", APCBundle(), @"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 @@ -539,6 +539,6 @@ - (NSString *)passwordForAuthManager:(id<SBBAuthManagerProtocol>) __unused authM

- (NSString *)noInternetString
{
return APCLocalizedString(@"No network connection. Please connect to the internet and try again.", @"No Internet");
return NSLocalizedStringWithDefaultValue(@"No network connection. Please connect to the internet and try again.", @"APCAppCore", APCBundle(), @"No network connection. Please connect to the internet and try again.", @"No Internet");
}
@end
6 changes: 3 additions & 3 deletions APCAppCore/APCAppCore/DataSubstrate/Model/APCUser+UserData.m
Expand Up @@ -40,16 +40,16 @@ @implementation APCUser (UserData)
Biologial Sex
****************/
+ (NSArray *) sexTypesInStringValue {
return @[ APCLocalizedString(@"Male", @""), APCLocalizedString(@"Female", @"")];
return @[ NSLocalizedStringWithDefaultValue(@"Male", @"APCAppCore", APCBundle(), @"Male", @""), NSLocalizedStringWithDefaultValue(@"Female", @"APCAppCore", APCBundle(), @"Female", @"")];
}

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

if ([stringValue isEqualToString:APCLocalizedString(@"Male", @"")]) {
if ([stringValue isEqualToString:NSLocalizedStringWithDefaultValue(@"Male", @"APCAppCore", APCBundle(), @"Male", @"")]) {
sexType = HKBiologicalSexMale;
}
else if ([stringValue isEqualToString:APCLocalizedString(@"Female", @"")]) {
else if ([stringValue isEqualToString:NSLocalizedStringWithDefaultValue(@"Female", @"APCAppCore", APCBundle(), @"Female", @"")]) {
sexType = HKBiologicalSexFemale;
}
else {
Expand Down
Expand Up @@ -56,11 +56,11 @@ - (void) handleFailureInFunction: (NSString *) __unused functionName
}

- (void) exitGracefully {
NSString *alertTitle = APCLocalizedString(@"Somethings Wrong!", @"");
NSString *alertTitle = NSLocalizedStringWithDefaultValue(@"Somethings Wrong!", @"APCAppCore", APCBundle(), @"Somethings Wrong!", @"");

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.", @"");
NSString *alertMessage = NSLocalizedStringWithDefaultValue(@"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.", @"APCAppCore", APCBundle(), @"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:APCLocalizedString(@"Okay", @"") style:UIAlertActionStyleCancel handler:^(UIAlertAction * __unused action) {
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:NSLocalizedStringWithDefaultValue(@"Okay", @"APCAppCore", APCBundle(), @"Okay", @"") style:UIAlertActionStyleCancel handler:^(UIAlertAction * __unused action) {
exit(0);
}];

Expand Down
4 changes: 2 additions & 2 deletions APCAppCore/APCAppCore/Library/Categories/NSDate+Helper.m
Expand Up @@ -147,11 +147,11 @@ -(NSString *) friendlyDescription
NSString * retValue;
if([date isEqual:today])
{
retValue = APCLocalizedString(@"Today", nil);
retValue = NSLocalizedStringWithDefaultValue(@"Today", @"APCAppCore", APCBundle(), @"Today", nil);
}
else if([date isEqual:yesterday])
{
retValue = APCLocalizedString(@"Yesterday", nil);
retValue = NSLocalizedStringWithDefaultValue(@"Yesterday", @"APCAppCore", APCBundle(), @"Yesterday", nil);
}
else if(([date laterDate:oneWeekAgo] == date) && ([date laterDate:tomorrow] == tomorrow))
{
Expand Down
20 changes: 10 additions & 10 deletions APCAppCore/APCAppCore/Library/Categories/NSError+APCAdditions.h
Expand Up @@ -33,16 +33,16 @@

#import <Foundation/Foundation.h>

FOUNDATION_EXPORT NSString * const kAPCServerBusyErrorMessage;
FOUNDATION_EXPORT NSString * const kAPCUnexpectedConditionErrorMessage;
FOUNDATION_EXPORT NSString * const kAPCNotConnectedErrorMessage;
FOUNDATION_EXPORT NSString * const kAPCServerUnderMaintanenceErrorMessage;
FOUNDATION_EXPORT NSString * const kAPCAccountAlreadyExistsErrorMessage;
FOUNDATION_EXPORT NSString * const kAPCAccountDoesNotExistErrorMessage;
FOUNDATION_EXPORT NSString * const kAPCBadEmailAddressErrorMessage;
FOUNDATION_EXPORT NSString * const kAPCBadPasswordErrorMessage;
FOUNDATION_EXPORT NSString * const kAPCNotReachableErrorMessage;
FOUNDATION_EXPORT NSString * const kAPCInvalidEmailAddressOrPasswordErrorMessage;
FOUNDATION_EXPORT NSString * kAPCServerBusyErrorMessage;
FOUNDATION_EXPORT NSString * kAPCUnexpectedConditionErrorMessage;
FOUNDATION_EXPORT NSString * kAPCNotConnectedErrorMessage;
FOUNDATION_EXPORT NSString * kAPCServerUnderMaintanenceErrorMessage;
FOUNDATION_EXPORT NSString * kAPCAccountAlreadyExistsErrorMessage;
FOUNDATION_EXPORT NSString * kAPCAccountDoesNotExistErrorMessage;
FOUNDATION_EXPORT NSString * kAPCBadEmailAddressErrorMessage;
FOUNDATION_EXPORT NSString * kAPCBadPasswordErrorMessage;
FOUNDATION_EXPORT NSString * kAPCNotReachableErrorMessage;
FOUNDATION_EXPORT NSString * kAPCInvalidEmailAddressOrPasswordErrorMessage;

@interface NSError (APCAdditions)

Expand Down
46 changes: 30 additions & 16 deletions APCAppCore/APCAppCore/Library/Categories/NSError+APCAdditions.m
Expand Up @@ -35,29 +35,43 @@
#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.";
NSString * const kAPCNotConnectedErrorMessage = @"You are currently not connected to the Internet. Please try again when you are connected to a network.";
NSString * const kAPCServerUnderMaintanenceErrorMessage = @"The study server is currently undergoing maintanence. Please try again soon.";
NSString * const kAPCAccountAlreadyExistsErrorMessage = @"An account has already been created for this email address. Please use a different email address, or sign in using the \"already participating\" link at the bottom of the Welcome page.";
NSString * const kAPCAccountDoesNotExistErrorMessage = @"There is no account registered for this email address.";
NSString * const kAPCBadEmailAddressErrorMessage = @"The email address submitted is not a valid email address. Please correct the email address and try again.";
NSString * const kAPCBadPasswordErrorMessage = @"The password you have entered is not a valid password. Please try again.";
NSString * const kAPCNotReachableErrorMessage = @"We are currently not able to reach the study server. Please retry in a few moments.";
NSString * const kAPCInvalidEmailAddressOrPasswordErrorMessage = @"Entered email address or password is not valid. Please correct the email address or password and try again.";
NSString * kAPCServerBusyErrorMessage;
NSString * kAPCUnexpectedConditionErrorMessage;
NSString * kAPCNotConnectedErrorMessage;
NSString * kAPCServerUnderMaintanenceErrorMessage;
NSString * kAPCAccountAlreadyExistsErrorMessage;
NSString * kAPCAccountDoesNotExistErrorMessage;
NSString * kAPCBadEmailAddressErrorMessage;
NSString * kAPCBadPasswordErrorMessage;
NSString * kAPCNotReachableErrorMessage;
NSString * kAPCInvalidEmailAddressOrPasswordErrorMessage;

static NSString * const oneTab = @" ";


@implementation NSError (APCAdditions)

+ (void)initialize
{
kAPCServerBusyErrorMessage = NSLocalizedStringWithDefaultValue(@"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.", @"APCAppCore", APCBundle(), @"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.", @"Error message when server is too busy to respond");
kAPCUnexpectedConditionErrorMessage = NSLocalizedStringWithDefaultValue(@"An unexpected network condition has occurred. Please try again soon.", @"APCAppCore", APCBundle(), @"An unexpected network condition has occurred. Please try again soon.", @"Error message indicating unexpected network problem");
kAPCNotConnectedErrorMessage = NSLocalizedStringWithDefaultValue(@"You are currently not connected to the Internet. Please try again when you are connected to a network.", @"APCAppCore", APCBundle(), @"You are currently not connected to the Internet. Please try again when you are connected to a network.", @"Error message when no network connection found");
kAPCServerUnderMaintanenceErrorMessage = NSLocalizedStringWithDefaultValue(@"The study server is currently undergoing maintanence. Please try again soon.", @"APCAppCore", APCBundle(), @"The study server is currently undergoing maintanence. Please try again soon.", @"Error message when server is undergoing maintenance and temporarily unavailable");
kAPCAccountAlreadyExistsErrorMessage = NSLocalizedStringWithDefaultValue(@"An account has already been created for this email address. Please use a different email address, or sign in using the \"already participating\" link at the bottom of the Welcome page.", @"APCAppCore", APCBundle(), @"An account has already been created for this email address. Please use a different email address, or sign in using the \"already participating\" link at the bottom of the Welcome page.", @"Error message when participant attempts to sign up for a new account using an email address already associated with an account in this study");
kAPCAccountDoesNotExistErrorMessage = NSLocalizedStringWithDefaultValue(@"There is no account registered for this email address and password combination.", @"APCAppCore", APCBundle(), @"There is no account registered for this email address and password combination.", @"Error message when participant attempts to sign in to an existing account with an incorrect email address or password");
kAPCBadEmailAddressErrorMessage = NSLocalizedStringWithDefaultValue(@"The email address submitted is not a valid email address. Please correct the email address and try again.", @"APCAppCore", APCBundle(), @"The email address submitted is not a valid email address. Please correct the email address and try again.", @"Error message when participant attempts to sign up using a non-valid email address");
kAPCBadPasswordErrorMessage = NSLocalizedStringWithDefaultValue(@"The password you have entered is not a valid password. Please try again.", @"APCAppCore", APCBundle(), @"The password you have entered is not a valid password. Please try again.", @"Error message when participant attempts to sign up with a non-valid password");
kAPCNotReachableErrorMessage = NSLocalizedStringWithDefaultValue(@"We are currently not able to reach the study server. Please retry in a few moments.", @"APCAppCore", APCBundle(), @"We are currently not able to reach the study server. Please retry in a few moments.", @"Error message when the app is unable to reach the Bridge server");
kAPCInvalidEmailAddressOrPasswordErrorMessage = NSLocalizedStringWithDefaultValue(@"Entered email address or password is not valid. Please correct the email address or password and try again.", @"APCAppCore", APCBundle(), @"Entered email address or password is not valid. Please correct the email address or password and try again.", @"Error message when participant attempts to sign up with a non-valid email address or password");
}

- (NSString*)checkMessageForNonUserTerms:(NSString*)message
{
if ([message containsString:@"NSError"] ||
[message containsString:@"NSURLError"] ||
[message rangeOfString:@"contact somebody" options:NSCaseInsensitiveSearch].location != NSNotFound)
{
return APCLocalizedString(@"An unknown error occurred", nil);
return NSLocalizedStringWithDefaultValue(@"An unknown error occurred", @"APCAppCore", APCBundle(), @"An unknown error occurred", nil);
}
return message;
}
Expand All @@ -79,19 +93,19 @@ - (NSString *)networkErrorMessage
NSString *message;

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

return message;
Expand Down
29 changes: 18 additions & 11 deletions APCAppCore/APCAppCore/Library/Categories/NSError+Bridge.m
Expand Up @@ -32,6 +32,7 @@
//

#import "NSError+Bridge.h"
#import "NSError+APCAdditions.h"
#import "APCLog.h"
#import <BridgeSDK/BridgeSDK.h>
#import "APCLog.h"
Expand All @@ -46,6 +47,12 @@

@implementation NSError (Bridge)

+ (void)initialize
{
// This class depends on strings that are localized in the +initialize method of NSError+APCAdditions, so we need to
// ensure that it has been initialized before anything in this class gets used
[NSError errorWithCode:0 domain:@"APCDummyErrorDomain" failureReason:nil recoverySuggestion:nil];
}

- (NSString*)bridgeErrorMessage
{
Expand All @@ -62,7 +69,7 @@ - (NSString*)bridgeErrorMessage

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

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

return message;
Expand Down
Expand Up @@ -93,7 +93,7 @@ - (NSArray*)locationArrayWithLocationManager:(CLLocationManager*)manager
}
else
{
speed = APCLocalizedString(@"invalid speed", nil);
speed = NSLocalizedStringWithDefaultValue(@"invalid speed", @"APCAppCore", APCBundle(), @"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 = APCLocalizedString(@"not available", nil);
floor = NSLocalizedStringWithDefaultValue(@"not available", @"APCAppCore", APCBundle(), @"not available", nil);
}
else
{
Expand Down
Expand Up @@ -40,7 +40,7 @@ + (UIAlertController *) simpleAlertWithTitle:(NSString *)title message:(NSString
{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];

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

return alertController;
Expand Down

0 comments on commit 8a01597

Please sign in to comment.