From 2101100720b36c33a460b6d2c87c5f6c72ad7f1a Mon Sep 17 00:00:00 2001 From: Erin Mounts Date: Mon, 30 Nov 2015 12:35:23 -0800 Subject: [PATCH] Enable localization of onboarding HTML content Xcode doesn't handle localization of resources in subdirectories very well (e.g., the HTML resources in RK apps having been added as a folder en masse rather than letting Xcode create a new group for them based on the folder name, so that they end up in an HTML subfolder within the app's Resources folder rather than in .lproj subfolders directly in the Resources folder). This goes along with the corresponding change in the app projects, i.e. remove the HTML directory from the project (removing references only) and re-add it, this time allowing Xcode to create a new HTML group rather than adding the directory itself. --- APCAppCore/APCAppCore/Consent/APCConsentTask.m | 6 +++--- APCAppCore/APCAppCore/Startup/APCAppDelegate.m | 4 ++-- .../UI/Onboarding/APCStudyDetailsViewController.m | 2 +- .../Onboarding/APCStudyOverviewCollectionViewController.m | 4 ++-- .../UI/TabBarControllers/Profile/APCProfileViewController.m | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/APCAppCore/APCAppCore/Consent/APCConsentTask.m b/APCAppCore/APCAppCore/Consent/APCConsentTask.m index 79abbde3..0e85e8c9 100644 --- a/APCAppCore/APCAppCore/Consent/APCConsentTask.m +++ b/APCAppCore/APCAppCore/Consent/APCConsentTask.m @@ -499,7 +499,7 @@ - (void)loadDocumentProperties:(NSDictionary*)properties if (documentHtmlContent != nil) { - NSString* path = [[NSBundle mainBundle] pathForResource:documentHtmlContent ofType:@"html" inDirectory:@"HTMLContent"]; + NSString* path = [[NSBundle mainBundle] pathForResource:documentHtmlContent ofType:@"html"]; NSAssert(path != nil, @"Unable to locate HTML file: %@", documentHtmlContent); if (path != nil) @@ -527,7 +527,7 @@ - (void)loadDocumentProperties:(NSDictionary*)properties NSString* htmlContent = [properties objectForKey:kHtmlContentTag]; if (htmlContent != nil) { - NSString* path = [[NSBundle mainBundle] pathForResource:htmlContent ofType:@"html" inDirectory:@"HTMLContent"]; + NSString* path = [[NSBundle mainBundle] pathForResource:htmlContent ofType:@"html"]; NSAssert(path != nil, @"Unable to locate HTML file: %@", htmlContent); NSError* error = nil; @@ -790,7 +790,7 @@ - (void)loadSections:(NSArray*)properties if (htmlContent != nil) { - NSString* path = [[NSBundle mainBundle] pathForResource:htmlContent ofType:@"html" inDirectory:@"HTMLContent"]; + NSString* path = [[NSBundle mainBundle] pathForResource:htmlContent ofType:@"html"]; NSAssert(path != nil, @"Unable to locate HTML file: %@", htmlContent); NSError* error = nil; diff --git a/APCAppCore/APCAppCore/Startup/APCAppDelegate.m b/APCAppCore/APCAppCore/Startup/APCAppDelegate.m index 1363b6e2..62eeec27 100644 --- a/APCAppCore/APCAppCore/Startup/APCAppDelegate.m +++ b/APCAppCore/APCAppCore/Startup/APCAppDelegate.m @@ -425,7 +425,7 @@ - (NSMutableArray*)consentSectionsAndHtmlContent:(NSString**)htmlContent if (documentHtmlContent != nil && htmlContent != nil) { - NSString* path = [[NSBundle mainBundle] pathForResource:documentHtmlContent ofType:@"html" inDirectory:@"HTMLContent"]; + NSString* path = [[NSBundle mainBundle] pathForResource:documentHtmlContent ofType:@"html"]; NSAssert(path != nil, @"Unable to locate HTML file: %@", documentHtmlContent); NSError* error = nil; @@ -492,7 +492,7 @@ - (NSMutableArray*)consentSectionsAndHtmlContent:(NSString**)htmlContent if (htmlContent != nil) { - NSString* path = [[NSBundle mainBundle] pathForResource:htmlContent ofType:@"html" inDirectory:@"HTMLContent"]; + NSString* path = [[NSBundle mainBundle] pathForResource:htmlContent ofType:@"html"]; NSAssert(path != nil, @"Unable to locate HTML file: %@", htmlContent); NSError* error = nil; diff --git a/APCAppCore/APCAppCore/UI/Onboarding/APCStudyDetailsViewController.m b/APCAppCore/APCAppCore/UI/Onboarding/APCStudyDetailsViewController.m index f5d03434..72cb94ee 100644 --- a/APCAppCore/APCAppCore/UI/Onboarding/APCStudyDetailsViewController.m +++ b/APCAppCore/APCAppCore/UI/Onboarding/APCStudyDetailsViewController.m @@ -55,7 +55,7 @@ - (void)viewDidLoad { self.title = self.studyDetails.caption; - NSString *filePath = [[NSBundle mainBundle] pathForResource:self.studyDetails.detailText ofType:@"html" inDirectory:@"HTMLContent"]; + NSString *filePath = [[NSBundle mainBundle] pathForResource:self.studyDetails.detailText ofType:@"html"]; NSURL *targetURL = [NSURL URLWithString:filePath]; NSURLRequest *request = [NSURLRequest requestWithURL:targetURL]; self.webView.delegate = self; diff --git a/APCAppCore/APCAppCore/UI/Onboarding/APCStudyOverviewCollectionViewController.m b/APCAppCore/APCAppCore/UI/Onboarding/APCStudyOverviewCollectionViewController.m index dedc208e..03ba5fbb 100644 --- a/APCAppCore/APCAppCore/UI/Onboarding/APCStudyOverviewCollectionViewController.m +++ b/APCAppCore/APCAppCore/UI/Onboarding/APCStudyOverviewCollectionViewController.m @@ -237,8 +237,8 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell } else { APCStudyOverviewCollectionViewCell *webViewCell = (APCStudyOverviewCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:kAPCStudyOverviewCollectionViewCellIdentifier forIndexPath:indexPath]; - NSString *filePath = [[NSBundle mainBundle] pathForResource: studyDetails.detailText ofType:@"html" inDirectory:@"HTMLContent"]; - NSAssert(filePath, @"Expecting file \"%@.html\" to be present in the \"HTMLContent\" directory, but didn't find it", studyDetails.detailText); + NSString *filePath = [[NSBundle mainBundle] pathForResource: studyDetails.detailText ofType:@"html"]; + NSAssert(filePath, @"Expecting file \"%@.html\" to be present in Resources, but didn't find it", studyDetails.detailText); NSURL *targetURL = [NSURL URLWithString:filePath]; NSURLRequest *request = [NSURLRequest requestWithURL:targetURL]; [webViewCell.webView loadRequest:request]; diff --git a/APCAppCore/APCAppCore/UI/TabBarControllers/Profile/APCProfileViewController.m b/APCAppCore/APCAppCore/UI/TabBarControllers/Profile/APCProfileViewController.m index c1b4c6d0..43f30dfa 100644 --- a/APCAppCore/APCAppCore/UI/TabBarControllers/Profile/APCProfileViewController.m +++ b/APCAppCore/APCAppCore/UI/TabBarControllers/Profile/APCProfileViewController.m @@ -1619,7 +1619,7 @@ - (IBAction)editFields:(UIBarButtonItem *)sender - (void)showPrivacyPolicy { APCWebViewController *webViewController = [[UIStoryboard storyboardWithName:@"APCOnboarding" bundle:[NSBundle appleCoreBundle]] instantiateViewControllerWithIdentifier:@"APCWebViewController"]; - NSString *filePath = [[NSBundle mainBundle] pathForResource: @"PrivacyPolicy" ofType:@"html" inDirectory:@"HTMLContent"]; + NSString *filePath = [[NSBundle mainBundle] pathForResource: @"PrivacyPolicy" ofType:@"html"]; NSURL *targetURL = [NSURL URLWithString:filePath]; NSURLRequest *request = [NSURLRequest requestWithURL:targetURL]; webViewController.title = NSLocalizedStringWithDefaultValue(@"Privacy Policy", @"APCAppCore", APCBundle(), @"Privacy Policy", @"");