Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

feature : use also localization files from App bundle #218

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions QBImagePicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -81,6 +83,8 @@

/* Begin PBXFileReference section */
07A50A481B331A840010E048 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/QBImagePicker.strings; sourceTree = "<group>"; };
2443056F2203022E00A673DE /* LocalizationHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LocalizationHelper.h; sourceTree = "<group>"; };
244305702203022E00A673DE /* LocalizationHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LocalizationHelper.m; sourceTree = "<group>"; };
74BB93661B2CE91A0044EB60 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/QBImagePicker.strings; sourceTree = "<group>"; };
790A850D1AE7D4D9008E2A80 /* QBSlomoIconView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QBSlomoIconView.h; sourceTree = "<group>"; };
790A850E1AE7D4D9008E2A80 /* QBSlomoIconView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QBSlomoIconView.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -160,6 +164,15 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
2443056E2203020100A673DE /* Utility */ = {
isa = PBXGroup;
children = (
2443056F2203022E00A673DE /* LocalizationHelper.h */,
244305702203022E00A673DE /* LocalizationHelper.m */,
);
name = Utility;
sourceTree = "<group>";
};
AA3AD0751ACFA22500BF523E /* Views */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -220,6 +233,7 @@
AAA8FE081ACDA079002A9710 /* QBImagePicker.h */,
AA3AD0751ACFA22500BF523E /* Views */,
AA3AD0761ACFA23300BF523E /* ViewControllers */,
2443056E2203020100A673DE /* Utility */,
AAF1CA241ACE5665005F6295 /* Resources */,
AAA8FE061ACDA079002A9710 /* Supporting Files */,
);
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion QBImagePicker/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.4.0</string>
<string>3.5.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
15 changes: 15 additions & 0 deletions QBImagePicker/LocalizationHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// LocalizationHelper.h
// QBImagePicker
//
// Created by Ganora Alberto on 31.01.19.
// Copyright © 2019 Katsuma Tanaka. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface LocalizationHelper : NSObject

NSString *QBImagePickerLocalizedString(NSString *key, NSString *comment, NSBundle *framworkBundle);

@end
33 changes: 33 additions & 0 deletions QBImagePicker/LocalizationHelper.m
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions QBImagePicker/QBAlbumsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand Down
17 changes: 9 additions & 8 deletions QBImagePicker/QBAssetsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand All @@ -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];
}
Expand All @@ -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];
}
Expand Down
2 changes: 1 addition & 1 deletion QBImagePickerController.podspec
Original file line number Diff line number Diff line change
@@ -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"
Expand Down