diff --git a/QBImagePicker.xcodeproj/project.pbxproj b/QBImagePicker.xcodeproj/project.pbxproj index 56a6f42e..21302402 100644 --- a/QBImagePicker.xcodeproj/project.pbxproj +++ b/QBImagePicker.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 244305712203022E00A673DE /* LocalizationHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 2443056F2203022E00A673DE /* LocalizationHelper.h */; }; + 244305722203022E00A673DE /* LocalizationHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 244305702203022E00A673DE /* LocalizationHelper.m */; }; 790A850F1AE7D4D9008E2A80 /* QBSlomoIconView.h in Headers */ = {isa = PBXBuildFile; fileRef = 790A850D1AE7D4D9008E2A80 /* QBSlomoIconView.h */; }; 790A85101AE7D4D9008E2A80 /* QBSlomoIconView.m in Sources */ = {isa = PBXBuildFile; fileRef = 790A850E1AE7D4D9008E2A80 /* QBSlomoIconView.m */; }; AA3AD06F1ACF9A3A00BF523E /* QBVideoIconView.h in Headers */ = {isa = PBXBuildFile; fileRef = AA3AD06D1ACF9A3A00BF523E /* QBVideoIconView.h */; }; @@ -81,6 +83,8 @@ /* Begin PBXFileReference section */ 07A50A481B331A840010E048 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/QBImagePicker.strings; sourceTree = ""; }; + 2443056F2203022E00A673DE /* LocalizationHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LocalizationHelper.h; sourceTree = ""; }; + 244305702203022E00A673DE /* LocalizationHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LocalizationHelper.m; sourceTree = ""; }; 74BB93661B2CE91A0044EB60 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/QBImagePicker.strings; sourceTree = ""; }; 790A850D1AE7D4D9008E2A80 /* QBSlomoIconView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QBSlomoIconView.h; sourceTree = ""; }; 790A850E1AE7D4D9008E2A80 /* QBSlomoIconView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QBSlomoIconView.m; sourceTree = ""; }; @@ -160,6 +164,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 2443056E2203020100A673DE /* Utility */ = { + isa = PBXGroup; + children = ( + 2443056F2203022E00A673DE /* LocalizationHelper.h */, + 244305702203022E00A673DE /* LocalizationHelper.m */, + ); + name = Utility; + sourceTree = ""; + }; AA3AD0751ACFA22500BF523E /* Views */ = { isa = PBXGroup; children = ( @@ -220,6 +233,7 @@ AAA8FE081ACDA079002A9710 /* QBImagePicker.h */, AA3AD0751ACFA22500BF523E /* Views */, AA3AD0761ACFA23300BF523E /* ViewControllers */, + 2443056E2203020100A673DE /* Utility */, AAF1CA241ACE5665005F6295 /* Resources */, AAA8FE061ACDA079002A9710 /* Supporting Files */, ); @@ -320,6 +334,7 @@ AA3AD0731ACFA06700BF523E /* QBVideoIndicatorView.h in Headers */, AAF1CA331ACE6FB5005F6295 /* QBAssetCell.h in Headers */, AAF1CA2F1ACE6E46005F6295 /* QBAssetsViewController.h in Headers */, + 244305712203022E00A673DE /* LocalizationHelper.h in Headers */, AAF1CA1A1ACE5467005F6295 /* QBAlbumCell.h in Headers */, AAA8FE5B1ACDA554002A9710 /* QBAlbumsViewController.h in Headers */, AA3AD06F1ACF9A3A00BF523E /* QBVideoIconView.h in Headers */, @@ -496,6 +511,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 244305722203022E00A673DE /* LocalizationHelper.m in Sources */, AAF1CA341ACE6FB5005F6295 /* QBAssetCell.m in Sources */, AA3AD0701ACF9A3A00BF523E /* QBVideoIconView.m in Sources */, 790A85101AE7D4D9008E2A80 /* QBSlomoIconView.m in Sources */, diff --git a/QBImagePicker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/QBImagePicker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/QBImagePicker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/QBImagePicker/Info.plist b/QBImagePicker/Info.plist index a8f98d8f..2bf762f6 100644 --- a/QBImagePicker/Info.plist +++ b/QBImagePicker/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 3.4.0 + 3.5.0 CFBundleSignature ???? CFBundleVersion diff --git a/QBImagePicker/LocalizationHelper.h b/QBImagePicker/LocalizationHelper.h new file mode 100644 index 00000000..b9b99ce2 --- /dev/null +++ b/QBImagePicker/LocalizationHelper.h @@ -0,0 +1,15 @@ +// +// LocalizationHelper.h +// QBImagePicker +// +// Created by Ganora Alberto on 31.01.19. +// Copyright © 2019 Katsuma Tanaka. All rights reserved. +// + +#import + +@interface LocalizationHelper : NSObject + +NSString *QBImagePickerLocalizedString(NSString *key, NSString *comment, NSBundle *framworkBundle); + +@end diff --git a/QBImagePicker/LocalizationHelper.m b/QBImagePicker/LocalizationHelper.m new file mode 100644 index 00000000..51269772 --- /dev/null +++ b/QBImagePicker/LocalizationHelper.m @@ -0,0 +1,33 @@ +// +// LocalizationHelper.m +// QBImagePicker +// +// Created by Ganora Alberto on 31.01.19. +// Copyright © 2019 Katsuma Tanaka. All rights reserved. +// + +#import "LocalizationHelper.h" + +@implementation LocalizationHelper + +NSString *QBImagePickerLocalizedString(NSString *key, NSString *comment, NSBundle *framworkBundle) +{ + return (QBImagePickerFrameworkString(key, comment, framworkBundle)); +} + +NSString *_QBImagePickerFrameworkString(NSString *key, NSBundle *framworkBundle) +{ + return ([framworkBundle localizedStringForKey:key value:nil table:@"QBImagePicker"]); +} + +NSString *QBImagePickerFrameworkString(NSString *key, NSString *comment, NSBundle *framworkBundle) +{ + NSString *localizedString = [[NSBundle mainBundle] localizedStringForKey:key value:nil table:@"QBImagePicker"]; + if(!localizedString || [localizedString isEqualToString:key]) + { + localizedString = _QBImagePickerFrameworkString(key, framworkBundle); + } + return( localizedString ? localizedString : key); +} + +@end diff --git a/QBImagePicker/QBAlbumsViewController.m b/QBImagePicker/QBAlbumsViewController.m index a08dfe28..675063d2 100644 --- a/QBImagePicker/QBAlbumsViewController.m +++ b/QBImagePicker/QBAlbumsViewController.m @@ -15,6 +15,7 @@ // ViewControllers #import "QBImagePickerController.h" #import "QBAssetsViewController.h" +#import "LocalizationHelper.h" static CGSize CGSizeScale(CGSize size, CGFloat scale) { return CGSizeMake(size.width * scale, size.height * scale); @@ -59,7 +60,7 @@ - (void)viewWillAppear:(BOOL)animated [super viewWillAppear:animated]; // Configure navigation item - self.navigationItem.title = NSLocalizedStringFromTableInBundle(@"albums.title", @"QBImagePicker", self.imagePickerController.assetBundle, nil); + self.navigationItem.title = QBImagePickerLocalizedString(@"albums.title", nil, self.imagePickerController.assetBundle); self.navigationItem.prompt = self.imagePickerController.prompt; // Show/hide 'Done' button @@ -134,9 +135,9 @@ - (void)updateSelectionInfo NSBundle *bundle = self.imagePickerController.assetBundle; NSString *format; if (selectedAssets.count > 1) { - format = NSLocalizedStringFromTableInBundle(@"assets.toolbar.items-selected", @"QBImagePicker", bundle, nil); + format = QBImagePickerLocalizedString(@"assets.toolbar.items-selected", nil, bundle); } else { - format = NSLocalizedStringFromTableInBundle(@"assets.toolbar.item-selected", @"QBImagePicker", bundle, nil); + format = QBImagePickerLocalizedString(@"assets.toolbar.item-selected", nil, bundle); } NSString *title = [NSString stringWithFormat:format, selectedAssets.count]; diff --git a/QBImagePicker/QBAssetsViewController.m b/QBImagePicker/QBAssetsViewController.m index 98177684..135ce438 100644 --- a/QBImagePicker/QBAssetsViewController.m +++ b/QBImagePicker/QBAssetsViewController.m @@ -13,6 +13,7 @@ #import "QBImagePickerController.h" #import "QBAssetCell.h" #import "QBVideoIndicatorView.h" +#import "LocalizationHelper.h" static CGSize CGSizeScale(CGSize size, CGFloat scale) { return CGSizeMake(size.width * scale, size.height * scale); @@ -214,9 +215,9 @@ - (void)updateSelectionInfo NSBundle *bundle = self.imagePickerController.assetBundle; NSString *format; if (selectedAssets.count > 1) { - format = NSLocalizedStringFromTableInBundle(@"assets.toolbar.items-selected", @"QBImagePicker", bundle, nil); + format = QBImagePickerLocalizedString(@"assets.toolbar.items-selected", nil, bundle); } else { - format = NSLocalizedStringFromTableInBundle(@"assets.toolbar.item-selected", @"QBImagePicker", bundle, nil); + format = QBImagePickerLocalizedString(@"assets.toolbar.item-selected", nil, bundle); } NSString *title = [NSString stringWithFormat:format, selectedAssets.count]; @@ -512,14 +513,14 @@ - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView NSString *format; if (numberOfPhotos == 1) { if (numberOfVideos == 1) { - format = NSLocalizedStringFromTableInBundle(@"assets.footer.photo-and-video", @"QBImagePicker", bundle, nil); + format = QBImagePickerLocalizedString(@"assets.footer.photo-and-video", nil, bundle); } else { - format = NSLocalizedStringFromTableInBundle(@"assets.footer.photo-and-videos", @"QBImagePicker", bundle, nil); + format = QBImagePickerLocalizedString(@"assets.footer.photo-and-videos", nil, bundle); } } else if (numberOfVideos == 1) { - format = NSLocalizedStringFromTableInBundle(@"assets.footer.photos-and-video", @"QBImagePicker", bundle, nil); + format = QBImagePickerLocalizedString(@"assets.footer.photos-and-video", nil, bundle); } else { - format = NSLocalizedStringFromTableInBundle(@"assets.footer.photos-and-videos", @"QBImagePicker", bundle, nil); + format = QBImagePickerLocalizedString(@"assets.footer.photos-and-videos", nil, bundle); } label.text = [NSString stringWithFormat:format, numberOfPhotos, numberOfVideos]; @@ -529,7 +530,7 @@ - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView case QBImagePickerMediaTypeImage: { NSString *key = (numberOfPhotos == 1) ? @"assets.footer.photo" : @"assets.footer.photos"; - NSString *format = NSLocalizedStringFromTableInBundle(key, @"QBImagePicker", bundle, nil); + NSString *format = QBImagePickerLocalizedString(key, nil, bundle); label.text = [NSString stringWithFormat:format, numberOfPhotos]; } @@ -538,7 +539,7 @@ - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView case QBImagePickerMediaTypeVideo: { NSString *key = (numberOfVideos == 1) ? @"assets.footer.video" : @"assets.footer.videos"; - NSString *format = NSLocalizedStringFromTableInBundle(key, @"QBImagePicker", bundle, nil); + NSString *format = QBImagePickerLocalizedString(key, nil, bundle); label.text = [NSString stringWithFormat:format, numberOfVideos]; } diff --git a/QBImagePickerController.podspec b/QBImagePickerController.podspec index d3e28441..43fd7d7f 100644 --- a/QBImagePickerController.podspec +++ b/QBImagePickerController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "QBImagePickerController" - s.version = "3.4.0" + s.version = "3.5.0" s.summary = "A clone of UIImagePickerController with multiple selection support." s.homepage = "https://github.com/questbeat/QBImagePicker" s.license = "MIT"