diff --git a/prefs/Global.h b/prefs/Global.h index 8237c2e..b675890 100644 --- a/prefs/Global.h +++ b/prefs/Global.h @@ -2,8 +2,8 @@ #pragma mark - Macros -#define LOCALIZE(key, table, comment) NSLocalizedStringFromTableInBundle(key, table ?: @"Localizable", globalBundle, comment) +#define LOCALIZE(key, table, comment) NSLocalizedStringFromTableInBundle(key, table ?: @"Localizable", cepheiGlobalBundle, comment) #pragma mark - Variables -static NSBundle *globalBundle; +extern NSBundle *cepheiGlobalBundle; diff --git a/prefs/Global.m b/prefs/Global.m index 6ba63ea..a1de4ab 100644 --- a/prefs/Global.m +++ b/prefs/Global.m @@ -1,8 +1,8 @@ @import Foundation; -static NSBundle *globalBundle; +NSBundle *cepheiGlobalBundle; __attribute__((constructor)) static void cepheiInit() { - globalBundle = [NSBundle bundleWithPath:@"/Library/PreferenceBundles/Cephei.bundle"]; + cepheiGlobalBundle = [NSBundle bundleWithPath:@"/Library/PreferenceBundles/Cephei.bundle"]; } diff --git a/prefs/HBLinkTableCell.m b/prefs/HBLinkTableCell.m index 2e033f9..a055be1 100644 --- a/prefs/HBLinkTableCell.m +++ b/prefs/HBLinkTableCell.m @@ -17,7 +17,7 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr self.selectionStyle = UITableViewCellSelectionStyleBlue; - UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"safari" inBundle:globalBundle]]; + UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"safari" inBundle:cepheiGlobalBundle]]; if (IS_IOS_OR_NEWER(iOS_7_0)) { imageView.image = [imageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; } diff --git a/prefs/HBPackageTableCell.m b/prefs/HBPackageTableCell.m index ce0ba76..d954227 100644 --- a/prefs/HBPackageTableCell.m +++ b/prefs/HBPackageTableCell.m @@ -21,7 +21,7 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr if (self) { UIImageView *imageView = (UIImageView *)self.accessoryView; - imageView.image = [UIImage imageNamed:@"package" inBundle:globalBundle]; + imageView.image = [UIImage imageNamed:@"package" inBundle:cepheiGlobalBundle]; [imageView sizeToFit]; self.avatarView.layer.cornerRadius = 4.f; diff --git a/prefs/HBRootListController.m b/prefs/HBRootListController.m index a53062b..32e3c65 100644 --- a/prefs/HBRootListController.m +++ b/prefs/HBRootListController.m @@ -39,7 +39,7 @@ - (void)loadView { } } if (icon == nil) { - icon = [UIImage imageNamed:@"heart" inBundle:globalBundle]; + icon = [UIImage imageNamed:@"heart" inBundle:cepheiGlobalBundle]; } self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:icon style:UIBarButtonItemStylePlain target:self action:@selector(hb_shareTapped:)]; } else { diff --git a/prefs/HBTwitterCell.m b/prefs/HBTwitterCell.m index 9aec085..04875be 100644 --- a/prefs/HBTwitterCell.m +++ b/prefs/HBTwitterCell.m @@ -59,7 +59,7 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr _user = user; UIImageView *imageView = (UIImageView *)self.accessoryView; - imageView.image = [UIImage imageNamed:@"twitter" inBundle:globalBundle]; + imageView.image = [UIImage imageNamed:@"twitter" inBundle:cepheiGlobalBundle]; if (IS_IOS_OR_NEWER(iOS_7_0)) { imageView.image = [imageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; } diff --git a/prefs/Localization.x b/prefs/Localization.x index 038a5e9..b58e85a 100644 --- a/prefs/Localization.x +++ b/prefs/Localization.x @@ -8,13 +8,15 @@ - (NSString *)localizedStringForKey:(NSString *)key value:(NSString *)value table:(NSString *)tableName { NSString *string = %orig; - if ((!string || [string isEqualToString:key] || [string isEqualToString:value]) && [self.bundleURL.pathComponents containsObject:@"PreferenceBundles"]) { - if (self != globalBundle) { - string = [globalBundle localizedStringForKey:key value:value table:tableName]; - } + if (cepheiGlobalBundle != nil) { + if ((string == nil || [string isEqualToString:key] || [string isEqualToString:value]) && [self.bundleURL.pathComponents containsObject:@"PreferenceBundles"]) { + if (self != cepheiGlobalBundle) { + string = [cepheiGlobalBundle localizedStringForKey:key value:value table:tableName]; + } - if ((!string || [string isEqualToString:key] || [string isEqualToString:value]) && self != globalBundle) { - string = [globalBundle localizedStringForKey:key value:value table:@"Common"]; + if ((string == nil || [string isEqualToString:key] || [string isEqualToString:value]) && self != cepheiGlobalBundle) { + string = [cepheiGlobalBundle localizedStringForKey:key value:value table:@"Common"]; + } } }