Skip to content

Commit

Permalink
Removed macro NSLocalizedStringUniversal in favor of direct usage of …
Browse files Browse the repository at this point in the history
…[[NSBundle bundleForClass: [self class]] localizedStringForKey:(key) value:@"" table:nil]
  • Loading branch information
Dirk- committed Sep 25, 2020
1 parent 1343f3c commit c93ae2f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 26 deletions.
8 changes: 4 additions & 4 deletions Hosts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 9;
CURRENT_PROJECT_VERSION = 10;
DEBUG_INFORMATION_FORMAT = dwarf;
DEPLOYMENT_POSTPROCESSING = NO;
DEVELOPMENT_TEAM = PZV4XW8XL7;
Expand Down Expand Up @@ -683,7 +683,7 @@
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 9;
CURRENT_PROJECT_VERSION = 10;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_POSTPROCESSING = NO;
DEVELOPMENT_TEAM = PZV4XW8XL7;
Expand Down Expand Up @@ -829,7 +829,7 @@
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 9;
CURRENT_PROJECT_VERSION = 10;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = PZV4XW8XL7;
GCC_DYNAMIC_NO_PIC = NO;
Expand Down Expand Up @@ -863,7 +863,7 @@
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 9;
CURRENT_PROJECT_VERSION = 10;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = PZV4XW8XL7;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
Expand Down
5 changes: 0 additions & 5 deletions HostsPrefpane/HostsPrefpane-Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif

// In case we run the Hosts code as a Pref Pane, NSLocalizedString does not help
#define NSLocalizedStringUniversal(key, comment) \
[[NSBundle bundleForClass: [self class]] localizedStringForKey:(key) value:@"" table:nil]

5 changes: 0 additions & 5 deletions Hosts_Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif

// In case we run the Hosts code as a Pref Pane, NSLocalizedString does not help
#define NSLocalizedStringUniversal(key, comment) \
[[NSBundle bundleForClass: [self class]] localizedStringForKey:(key) value:@"" table:nil]

11 changes: 7 additions & 4 deletions pm/controllers/NLPERMANENTMARKERSHOSTSListController.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ - (IBAction) confirmDeleteItem:(id)sender {
NSUInteger at_index = [self selectionIndex];
NLPERMANENTMARKERSHOSTSHostEntry *entry = [[self arrangedObjects] objectAtIndex:at_index];

NSString *title = NSLocalizedStringUniversal(@"Confirm deletion", @"deletion: title");
NSString *description = NSLocalizedStringUniversal(
@"Are you sure you want to permanently remove:\n%@ from /etc/hosts?", @"deletion: message format string");
NSString *title = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Confirm deletion" value:@"" table:nil];
NSString *description = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Are you sure you want to permanently remove:\n%@ from /etc/hosts?" value:@"" table:nil];
description = [NSString stringWithFormat:description, [entry toString]];
NSAlert *alert = [NSAlert alertWithMessageText:title defaultButton:NSLocalizedStringUniversal(@"Yes", nil) alternateButton:NSLocalizedStringUniversal(@"No", nil) otherButton:nil informativeTextWithFormat:@"%@", description];
NSAlert *alert = [NSAlert alertWithMessageText:title
defaultButton:[[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Yes" value:@"" table:nil]
alternateButton:[[NSBundle bundleForClass: [self class]] localizedStringForKey:@"No" value:@"" table:nil]
otherButton:nil
informativeTextWithFormat:@"%@", description];
[alert beginSheetModalForWindow:[[NSApplication sharedApplication] mainWindow] modalDelegate:self didEndSelector:@selector(alertEnded:code:context:) contextInfo:NULL];
}

Expand Down
8 changes: 4 additions & 4 deletions pm/models/NLPERMANENTMARKERSHOSTSFileModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ - (void) insertObject:(id)object inHostsAtIndex:(NSUInteger) index {
if (undoManager != nil) {
[[undoManager prepareWithInvocationTarget:self] removeObjectFromHostsAtIndex:index];
if ([undoManager isUndoing]) {
NSString * undoActionName = NSLocalizedStringUniversal(@"Delete host entry", @"undo: redo insert");
NSString * undoActionName = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Delete host entry" value:@"" table:nil];
[undoManager setActionName:undoActionName];
} else {
NSString * undoActionName = NSLocalizedStringUniversal(@"Insert host entry", @"undo: undo delete");
NSString * undoActionName = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Insert host entry" value:@"" table:nil];
[undoManager setActionName:undoActionName];
}
}
Expand All @@ -83,10 +83,10 @@ - (void) removeObjectFromHostsAtIndex:(NSUInteger) index {
[undoManager removeAllActionsWithTarget:deletedObject];
[[undoManager prepareWithInvocationTarget:self] insertObject:deletedObject inHostsAtIndex:index];
if ([undoManager isUndoing]) {
NSString * undoActionName = NSLocalizedStringUniversal(@"Insert host entry", @"undo: redo delete");
NSString * undoActionName = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Insert host entry" value:@"" table:nil];
[undoManager setActionName:undoActionName];
} else {
NSString * undoActionName = NSLocalizedStringUniversal(@"Delete host entry", @"undo: undo insert");
NSString * undoActionName = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Delete host entry" value:@"" table:nil];
[undoManager setActionName:undoActionName];
}
}
Expand Down
7 changes: 3 additions & 4 deletions pm/models/NLPERMANENTMARKERSHOSTSHostEntry.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ - (void) pushUndoState:(NSDictionary *)change withManager:(NSUndoManager *)undoM
}
NSLog(@"old value %@", oldValue);
[[undoManager prepareWithInvocationTarget:self] setValue:oldValue forKeyPath:keyPath];
NSString * undoActionName = NSLocalizedStringUniversal(@"Edit", @"undo: undo edit");
NSString * undoActionName = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Edit" value:@"" table:nil];
[undoManager setActionName:undoActionName];

}
Expand All @@ -101,7 +101,7 @@ - (BOOL) validateAddress:(id *)ioValue error:(NSError **)outError {
} else {
NSLog(@"is not an ip");
if (outError != NULL) {
NSString * errorStr = NSLocalizedStringUniversal(@"Please enter a valid ip address", @"validation: valid ip address");
NSString * errorStr = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Please enter a valid ip address" value:@"" table:nil];
NSDictionary * userInfoDict = [NSDictionary dictionaryWithObject:errorStr
forKey:NSLocalizedDescriptionKey];
NSError *error = [NSError errorWithDomain:PM_HOST_ENTRY_ERROR_DOMAIN
Expand Down Expand Up @@ -130,8 +130,7 @@ - (BOOL) validateHostnames:(id *)ioValue error:(NSError **) outError {
return YES;
} else {
if (outError != NULL) {
NSString * errorStr = NSLocalizedStringUniversal(@"Please enter a valid hostname",
@"validation: valid hostname");
NSString * errorStr = [[NSBundle bundleForClass: [self class]] localizedStringForKey:@"Please enter a valid hostname" value:@"" table:nil];
NSDictionary * userInfoDict = [NSDictionary dictionaryWithObject:errorStr
forKey:NSLocalizedDescriptionKey];
NSError *error = [NSError errorWithDomain:PM_HOST_ENTRY_ERROR_DOMAIN
Expand Down

0 comments on commit c93ae2f

Please sign in to comment.