Skip to content

Commit

Permalink
[prefs] Oops, fix the cepheiGlobalBundle (shouldn’t have been static)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirb committed Aug 25, 2020
1 parent dc7273c commit ab3bcb0
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions prefs/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 2 additions & 2 deletions prefs/Global.m
Original file line number Diff line number Diff line change
@@ -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"];
}
2 changes: 1 addition & 1 deletion prefs/HBLinkTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
2 changes: 1 addition & 1 deletion prefs/HBPackageTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion prefs/HBRootListController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion prefs/HBTwitterCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
14 changes: 8 additions & 6 deletions prefs/Localization.x
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
}
}
}

Expand Down

0 comments on commit ab3bcb0

Please sign in to comment.