aboutsummaryrefslogtreecommitdiffstats
path: root/Framework/MASLocalization.m
diff options
context:
space:
mode:
Diffstat (limited to 'Framework/MASLocalization.m')
-rw-r--r--Framework/MASLocalization.m17
1 files changed, 9 insertions, 8 deletions
diff --git a/Framework/MASLocalization.m b/Framework/MASLocalization.m
index 9561470..d5f0c8a 100644
--- a/Framework/MASLocalization.m
+++ b/Framework/MASLocalization.m
@@ -6,12 +6,13 @@
// and the Localized.strings file won’t be bundled correctly.
// See https://github.com/shpakovski/MASShortcut/issues/74
NSString *MASLocalizedString(NSString *key, NSString *comment) {
- 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"];
+ static NSBundle *localizationBundle = nil;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ NSURL *cocoaPodsBundleURL = [[NSBundle mainBundle] URLForResource:@"MASShortcut" withExtension:@"bundle"];
+ localizationBundle = cocoaPodsBundleURL ?
+ [NSBundle bundleWithURL:cocoaPodsBundleURL] :
+ [NSBundle bundleForClass:[MASShortcut class]];
+ });
+ return [localizationBundle localizedStringForKey:key value:@"XXX" table:@"Localizable"];
}