aboutsummaryrefslogtreecommitdiffstats
path: root/Framework/MASLocalization.m
blob: d5f0c8aa39d2a317f9376462456722680dc7dbf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#import "MASLocalization.h"
#import "MASShortcut.h"

// The CocoaPods trickery here is needed because when the code
// is built as a part of CocoaPods, it wont make a separate framework
// and the Localized.strings file wont be bundled correctly.
// See https://github.com/shpakovski/MASShortcut/issues/74
NSString *MASLocalizedString(NSString *key, NSString *comment) {
    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"];
}