diff --git a/Classes/ELCImagePicker/ELC.h b/Classes/ELCImagePicker/ELC.h new file mode 100644 index 0000000..dcdb9b3 --- /dev/null +++ b/Classes/ELCImagePicker/ELC.h @@ -0,0 +1,7 @@ +@interface ELC : NSObject + ++ (void)setAlwaysUseMainBundle:(BOOL)alwaysUseMainBundle; ++ (NSBundle *)bundle; ++ (NSString *)LocalizedString:(NSString *)key; + +@end diff --git a/Classes/ELCImagePicker/ELC.m b/Classes/ELCImagePicker/ELC.m new file mode 100644 index 0000000..a27f7a4 --- /dev/null +++ b/Classes/ELCImagePicker/ELC.m @@ -0,0 +1,28 @@ +#import "ELC.h" + +static BOOL _alwaysUseMainBundle = NO; + +@implementation ELC + ++ (void)setAlwaysUseMainBundle:(BOOL)alwaysUseMainBundle { + _alwaysUseMainBundle = alwaysUseMainBundle; +} + ++ (NSBundle *)bundle { + if (_alwaysUseMainBundle) { + return [NSBundle mainBundle]; + } + return [NSBundle bundleWithPath:[[NSBundle mainBundle] + pathForResource: @"ELCImagePickerController" + ofType: @"bundle"]]; +} + ++ (NSString *)LocalizedString:(NSString *)key { + return NSLocalizedStringFromTableInBundle( + key, + @"ELCImagePickerController", + [ELC bundle], + nil); +} + +@end diff --git a/Classes/ELCImagePicker/ELCAlbumPickerController.m b/Classes/ELCImagePicker/ELCAlbumPickerController.m index e375a0a..5ff8266 100755 --- a/Classes/ELCImagePicker/ELCAlbumPickerController.m +++ b/Classes/ELCImagePicker/ELCAlbumPickerController.m @@ -9,6 +9,7 @@ #import "ELCImagePickerController.h" #import "ELCAssetTablePicker.h" #import +#import "ELC.h" @interface ELCAlbumPickerController () @@ -27,8 +28,7 @@ - (void)viewDidLoad { [super viewDidLoad]; [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone]; - - [self.navigationItem setTitle:NSLocalizedString(@"Loading...", nil)]; + [self.navigationItem setTitle:[ELC LocalizedString:@"Loading..."]]; UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self.parent action:@selector(cancelImagePicker)]; [self.navigationItem setRightBarButtonItem:cancelButton]; @@ -70,12 +70,12 @@ - (void)viewDidLoad void (^assetGroupEnumberatorFailure)(NSError *) = ^(NSError *error) { if ([ALAssetsLibrary authorizationStatus] == ALAuthorizationStatusDenied) { - NSString *errorMessage = NSLocalizedString(@"This app does not have access to your photos or videos. You can enable access in Privacy Settings.", nil); - [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Access Denied", nil) message:errorMessage delegate:nil cancelButtonTitle:NSLocalizedString(@"Ok", nil) otherButtonTitles:nil] show]; + NSString *errorMessage = [ELC LocalizedString:@"This app does not have access to your photos or videos. You can enable access in Privacy Settings."]; + [[[UIAlertView alloc] initWithTitle:[ELC LocalizedString:@"Access Denied"] message:errorMessage delegate:nil cancelButtonTitle:[ELC LocalizedString:@"Ok"] otherButtonTitles:nil] show]; } else { NSString *errorMessage = [NSString stringWithFormat:@"Album Error: %@ - %@", [error localizedDescription], [error localizedRecoverySuggestion]]; - [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) message:errorMessage delegate:nil cancelButtonTitle:NSLocalizedString(@"Ok", nil) otherButtonTitles:nil] show]; + [[[UIAlertView alloc] initWithTitle:[ELC LocalizedString:@"Error"] message:errorMessage delegate:nil cancelButtonTitle:[ELC LocalizedString:@"Ok"] otherButtonTitles:nil] show]; } [self.navigationItem setTitle:nil]; @@ -106,7 +106,7 @@ - (void)viewWillDisappear:(BOOL)animated { - (void)reloadTableView { [self.tableView reloadData]; - [self.navigationItem setTitle:NSLocalizedString(@"Select an Album", nil)]; + [self.navigationItem setTitle:[ELC LocalizedString:@"Select an Album"]]; } - (BOOL)shouldSelectAsset:(ELCAsset *)asset previousCount:(NSUInteger)previousCount diff --git a/Classes/ELCImagePicker/ELCAssetTablePicker.m b/Classes/ELCImagePicker/ELCAssetTablePicker.m index 24830be..1d92021 100755 --- a/Classes/ELCImagePicker/ELCAssetTablePicker.m +++ b/Classes/ELCImagePicker/ELCAssetTablePicker.m @@ -10,6 +10,7 @@ #import "ELCAsset.h" #import "ELCAlbumPickerController.h" #import "ELCConsole.h" +#import "ELC.h" @interface ELCAssetTablePicker () @@ -45,7 +46,7 @@ - (void)viewDidLoad } else { UIBarButtonItem *doneButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneAction:)]; [self.navigationItem setRightBarButtonItem:doneButtonItem]; - [self.navigationItem setTitle:NSLocalizedString(@"Loading...", nil)]; + [self.navigationItem setTitle:[ELC LocalizedString:@"Loading..."]]; } [self performSelectorInBackground:@selector(preparePhotos) withObject:nil]; @@ -118,8 +119,8 @@ - (void)preparePhotos atScrollPosition:UITableViewScrollPositionBottom animated:NO]; } - - [self.navigationItem setTitle:self.singleSelection ? NSLocalizedString(@"Pick Photo", nil) : NSLocalizedString(@"Pick Photos", nil)]; + + [self.navigationItem setTitle:self.singleSelection ? [ELC LocalizedString:@"Pick Photo"] : [ELC LocalizedString:@"Pick Photos"]]; }); } } diff --git a/Classes/ELCImagePicker/ELCImagePickerController.m b/Classes/ELCImagePicker/ELCImagePickerController.m index b7f3eda..4396f30 100755 --- a/Classes/ELCImagePicker/ELCImagePickerController.m +++ b/Classes/ELCImagePicker/ELCImagePickerController.m @@ -14,6 +14,7 @@ #import #import #import "ELCConsole.h" +#import "ELC.h" @implementation ELCImagePickerController @@ -71,13 +72,13 @@ - (BOOL)shouldSelectAsset:(ELCAsset *)asset previousCount:(NSUInteger)previousCo { BOOL shouldSelect = previousCount < self.maximumImagesCount; if (!shouldSelect) { - NSString *title = [NSString stringWithFormat:NSLocalizedString(@"Only %d photos please!", nil), self.maximumImagesCount]; - NSString *message = [NSString stringWithFormat:NSLocalizedString(@"You can only send %d photos at a time.", nil), self.maximumImagesCount]; + NSString *title = [NSString stringWithFormat:[ELC LocalizedString:@"Only %d photos please!"], self.maximumImagesCount]; + NSString *message = [NSString stringWithFormat:[ELC LocalizedString:@"You can only send %d photos at a time."], self.maximumImagesCount]; [[[UIAlertView alloc] initWithTitle:title message:message delegate:nil cancelButtonTitle:nil - otherButtonTitles:NSLocalizedString(@"Okay", nil), nil] show]; + otherButtonTitles:[ELC LocalizedString:@"Okay"], nil] show]; } return shouldSelect; } diff --git a/Classes/ELCImagePicker/Resources/en.lproj/ELCImagePickerController.strings b/Classes/ELCImagePicker/Resources/en.lproj/ELCImagePickerController.strings new file mode 100644 index 0000000..bcdcf54 Binary files /dev/null and b/Classes/ELCImagePicker/Resources/en.lproj/ELCImagePickerController.strings differ diff --git a/Classes/ELCImagePicker/Resources/ja.lproj/ELCImagePickerController.strings b/Classes/ELCImagePicker/Resources/ja.lproj/ELCImagePickerController.strings new file mode 100644 index 0000000..16b302b Binary files /dev/null and b/Classes/ELCImagePicker/Resources/ja.lproj/ELCImagePickerController.strings differ diff --git a/Classes/ELCImagePickerDemoViewController.m b/Classes/ELCImagePickerDemoViewController.m index 0b53ef2..a4756dd 100644 --- a/Classes/ELCImagePickerDemoViewController.m +++ b/Classes/ELCImagePickerDemoViewController.m @@ -9,7 +9,7 @@ #import "ELCImagePickerDemoAppDelegate.h" #import "ELCImagePickerDemoViewController.h" #import - +#import "ELC.h" @interface ELCImagePickerDemoViewController () @@ -23,6 +23,7 @@ @implementation ELCImagePickerDemoViewController - (IBAction)launchController { + [ELC setAlwaysUseMainBundle:YES]; ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initImagePicker]; elcPicker.maximumImagesCount = 100; //Set the maximum number of images to select to 100 diff --git a/ELCImagePickerController.podspec b/ELCImagePickerController.podspec index 89e3c3a..2665be3 100644 --- a/ELCImagePickerController.podspec +++ b/ELCImagePickerController.podspec @@ -13,6 +13,7 @@ Pod::Spec.new do |s| } s.platform = :ios, '6.0' s.resources = 'Classes/**/*.{xib,png}' + s.resource_bundles = { 'ELCImagePickerController' => 'Classes/**/*.lproj' } s.source_files = 'Classes/ELCImagePicker/*.{h,m}' s.framework = 'Foundation', 'UIKit', 'AssetsLibrary', 'CoreLocation' s.requires_arc = true diff --git a/ELCImagePickerDemo.xcodeproj/project.pbxproj b/ELCImagePickerDemo.xcodeproj/project.pbxproj index eeecc92..0436cc0 100755 --- a/ELCImagePickerDemo.xcodeproj/project.pbxproj +++ b/ELCImagePickerDemo.xcodeproj/project.pbxproj @@ -28,6 +28,9 @@ 83C6BC9714476B280064D71D /* elc-ios-icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 83C6BC9514476B280064D71D /* elc-ios-icon@2x.png */; }; 83C6BC9814476B280064D71D /* elc-ios-icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 83C6BC9614476B280064D71D /* elc-ios-icon.png */; }; E29A5E3C1239C42A008BB149 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E29A5E3B1239C42A008BB149 /* AssetsLibrary.framework */; }; + E507C28E1A6DED6F00191D11 /* ELCImagePickerController.strings in Resources */ = {isa = PBXBuildFile; fileRef = E507C2891A6DED6F00191D11 /* ELCImagePickerController.strings */; }; + E507C28F1A6DED6F00191D11 /* ELCImagePickerController.strings in Resources */ = {isa = PBXBuildFile; fileRef = E507C28C1A6DED6F00191D11 /* ELCImagePickerController.strings */; }; + E507C2921A6DF4A400191D11 /* ELC.m in Sources */ = {isa = PBXBuildFile; fileRef = E507C2911A6DF4A400191D11 /* ELC.m */; }; F1DF7842196FA475003524A2 /* ELCConsole.m in Sources */ = {isa = PBXBuildFile; fileRef = F1DF783F196FA475003524A2 /* ELCConsole.m */; }; F1DF7843196FA475003524A2 /* ELCOverlayImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = F1DF7841196FA475003524A2 /* ELCOverlayImageView.m */; }; /* End PBXBuildFile section */ @@ -67,6 +70,10 @@ 8D1107310486CEB800E47090 /* ELCImagePickerDemo-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "ELCImagePickerDemo-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; A58058B417EB865B0078600C /* ELCAssetPickerFilterDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ELCAssetPickerFilterDelegate.h; sourceTree = ""; }; E29A5E3B1239C42A008BB149 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; }; + E507C28A1A6DED6F00191D11 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ELCImagePickerController.strings; sourceTree = ""; }; + E507C28D1A6DED6F00191D11 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = ELCImagePickerController.strings; sourceTree = ""; }; + E507C2901A6DF4A400191D11 /* ELC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ELC.h; sourceTree = ""; }; + E507C2911A6DF4A400191D11 /* ELC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ELC.m; sourceTree = ""; }; F1DF783E196FA475003524A2 /* ELCConsole.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ELCConsole.h; sourceTree = ""; }; F1DF783F196FA475003524A2 /* ELCConsole.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ELCConsole.m; sourceTree = ""; }; F1DF7840196FA475003524A2 /* ELCOverlayImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ELCOverlayImageView.h; sourceTree = ""; }; @@ -144,6 +151,8 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + E507C2881A6DED6F00191D11 /* ja.lproj */, + E507C28B1A6DED6F00191D11 /* en.lproj */, 1A4C631217380272001E0978 /* Overlay.png */, 1A4C631317380272001E0978 /* Overlay@2x.png */, 83C6BC9514476B280064D71D /* elc-ios-icon@2x.png */, @@ -169,6 +178,8 @@ 4252A0981593013500086D05 /* ELCImagePicker */ = { isa = PBXGroup; children = ( + E507C2901A6DF4A400191D11 /* ELC.h */, + E507C2911A6DF4A400191D11 /* ELC.m */, 1A2C0FFD17026CF0004FAFA0 /* ELCAlbumPickerController.h */, 1A2C0FFE17026CF0004FAFA0 /* ELCAlbumPickerController.m */, 1A2C0FFF17026CF0004FAFA0 /* ELCAsset.h */, @@ -190,6 +201,24 @@ path = ELCImagePicker; sourceTree = ""; }; + E507C2881A6DED6F00191D11 /* ja.lproj */ = { + isa = PBXGroup; + children = ( + E507C2891A6DED6F00191D11 /* ELCImagePickerController.strings */, + ); + name = ja.lproj; + path = Classes/ELCImagePicker/Resources/ja.lproj; + sourceTree = ""; + }; + E507C28B1A6DED6F00191D11 /* en.lproj */ = { + isa = PBXGroup; + children = ( + E507C28C1A6DED6F00191D11 /* ELCImagePickerController.strings */, + ); + name = en.lproj; + path = Classes/ELCImagePicker/Resources/en.lproj; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -228,6 +257,8 @@ Japanese, French, German, + ja, + en, ); mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; projectDirPath = ""; @@ -248,6 +279,8 @@ 83C6BC9714476B280064D71D /* elc-ios-icon@2x.png in Resources */, 83C6BC9814476B280064D71D /* elc-ios-icon.png in Resources */, 230644BC15F8C0BB007679C7 /* MainWindow-iPad.xib in Resources */, + E507C28E1A6DED6F00191D11 /* ELCImagePickerController.strings in Resources */, + E507C28F1A6DED6F00191D11 /* ELCImagePickerController.strings in Resources */, 0B67B05B17E0ED1F002CC2C5 /* Default-568h@2x.png in Resources */, 1A4C631417380272001E0978 /* Overlay.png in Resources */, 1A4C631517380272001E0978 /* Overlay@2x.png in Resources */, @@ -261,6 +294,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + E507C2921A6DF4A400191D11 /* ELC.m in Sources */, 1D60589B0D05DD56006BFB54 /* main.m in Sources */, 1D3623260D0F684500981E51 /* ELCImagePickerDemoAppDelegate.m in Sources */, F1DF7842196FA475003524A2 /* ELCConsole.m in Sources */, @@ -276,6 +310,25 @@ }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXVariantGroup section */ + E507C2891A6DED6F00191D11 /* ELCImagePickerController.strings */ = { + isa = PBXVariantGroup; + children = ( + E507C28A1A6DED6F00191D11 /* ja */, + ); + name = ELCImagePickerController.strings; + sourceTree = ""; + }; + E507C28C1A6DED6F00191D11 /* ELCImagePickerController.strings */ = { + isa = PBXVariantGroup; + children = ( + E507C28D1A6DED6F00191D11 /* en */, + ); + name = ELCImagePickerController.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ 1D6058940D05DD3E006BFB54 /* Debug */ = { isa = XCBuildConfiguration;