From ded95506c6bc8f6c839b1efaf2fc04923498e894 Mon Sep 17 00:00:00 2001 From: Allan Beaufour Date: Wed, 7 Oct 2015 12:52:59 -0400 Subject: fixes localized strings when using CocoaPods Puts strings inside a MASShortcut resource bundle, and looks for locallized strings inside that bundle when used as a CocoaPod --- Framework/MASLocalization.m | 8 +++++++- MASShortcut.podspec | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Framework/MASLocalization.m b/Framework/MASLocalization.m index 7f395a9..a36d3a4 100644 --- a/Framework/MASLocalization.m +++ b/Framework/MASLocalization.m @@ -2,6 +2,12 @@ #import "MASShortcut.h" NSString *MASLocalizedString(NSString *key, NSString *comment) { - NSBundle *frameworkBundle = [NSBundle bundleForClass:[MASShortcut class]]; + NSBundle *frameworkBundle = nil; +#ifdef COCOAPODS + NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:@"MASShortcut" withExtension:@"bundle"]; + frameworkBundle = [NSBundle bundleWithURL:bundleURL]; +#else + frameworkBundle = [NSBundle bundleForClass:[MASShortcut class]]; +#endif return [frameworkBundle localizedStringForKey:key value:@"XXX" table:@"Localizable"]; } diff --git a/MASShortcut.podspec b/MASShortcut.podspec index 2b66035..8369046 100644 --- a/MASShortcut.podspec +++ b/MASShortcut.podspec @@ -1,3 +1,4 @@ +# coding: utf-8 Pod::Spec.new do |s| s.name = 'MASShortcut' s.version = '2.3.1' @@ -14,4 +15,5 @@ Pod::Spec.new do |s| s.exclude_files = 'Framework/*Tests.m' s.osx.frameworks = 'Carbon', 'AppKit' s.requires_arc = true + s.osx.resource_bundles = { 'MASShortcut' => ['*.lproj'] } end -- cgit v1.2.3