From 0b16eeff801f588b71ed70183ae45f027d65cf2b Mon Sep 17 00:00:00 2001 From: Shawn Schantz Date: Thu, 14 Oct 2021 14:28:45 +0700 Subject: [PATCH] externalize strings for alerts and download status --- .../KMAboutWindow/KMAboutWindowController.m | 5 +++- .../KMConfigurationWindowController.m | 9 +++---- .../KMInfoWindow/KMInfoWindowController.m | 3 ++- .../Keyman4MacIM/KMInputMethodAppDelegate.m | 13 +++++----- .../Keyman4MacIM/Localizable.strings | 26 ++++++++++++++++--- 5 files changed, 39 insertions(+), 17 deletions(-) diff --git a/mac/Keyman4MacIM/Keyman4MacIM/KMAboutWindow/KMAboutWindowController.m b/mac/Keyman4MacIM/Keyman4MacIM/KMAboutWindow/KMAboutWindowController.m index e4e9045c2d..822b5d47de 100644 --- a/mac/Keyman4MacIM/Keyman4MacIM/KMAboutWindow/KMAboutWindowController.m +++ b/mac/Keyman4MacIM/Keyman4MacIM/KMAboutWindow/KMAboutWindowController.m @@ -32,8 +32,11 @@ [self.window setBackgroundColor:[NSColor whiteColor]]; KeymanVersionInfo versionInfo = [[self AppDelegate] versionInfo]; + NSString *versionString = NSLocalizedString(@"version-label-text", nil); + [self.versionLabel setStringValue:[NSString localizedStringWithFormat:versionString, versionInfo.versionWithTag]]; +/* [self.versionLabel setStringValue:[NSString stringWithFormat:@"Version %@", versionInfo.versionWithTag]]; - +*/ NSMutableString *copyrightInfo = [[NSMutableString alloc] initWithString: [[[NSBundle mainBundle] infoDictionary] objectForKey:@"NSHumanReadableCopyright"]]; [self.copyrightLabel setStringValue:copyrightInfo]; diff --git a/mac/Keyman4MacIM/Keyman4MacIM/KMConfiguration/KMConfigurationWindowController.m b/mac/Keyman4MacIM/Keyman4MacIM/KMConfiguration/KMConfigurationWindowController.m index d907edc413..638b3bf367 100644 --- a/mac/Keyman4MacIM/Keyman4MacIM/KMConfiguration/KMConfigurationWindowController.m +++ b/mac/Keyman4MacIM/Keyman4MacIM/KMConfiguration/KMConfigurationWindowController.m @@ -453,12 +453,11 @@ if (!didUnzip) { NSAlert *failure = [[NSAlert alloc] init]; - [failure addButtonWithTitle:NSLocalizedString(@"OK", @"Alert button")]; - [failure setMessageText:NSLocalizedString(@"message-keyboard-file-unreadable", nil)]; - /* + [failure addButtonWithTitle:NSLocalizedString(@"button-keyboard-file-unreadable", @"Alert button")]; + NSString *errorString = NSLocalizedString(@"message-keyboard-file-unreadable", nil); - [failure setMessageText:[NSString localizedStringWithFormat:errorString, kmpFile]]; - */ + [failure setMessageText:[NSString localizedStringWithFormat:errorString, kmpFile.lastPathComponent]]; + [failure setIcon:[[NSBundle mainBundle] imageForResource:@"logo.png"]]; [failure setAlertStyle:NSWarningAlertStyle]; [failure beginSheetModalForWindow:self.window diff --git a/mac/Keyman4MacIM/Keyman4MacIM/KMInfoWindow/KMInfoWindowController.m b/mac/Keyman4MacIM/Keyman4MacIM/KMInfoWindow/KMInfoWindowController.m index 7667d12801..e8d1c159f1 100644 --- a/mac/Keyman4MacIM/Keyman4MacIM/KMInfoWindow/KMInfoWindowController.m +++ b/mac/Keyman4MacIM/Keyman4MacIM/KMInfoWindow/KMInfoWindowController.m @@ -27,7 +27,8 @@ - (void)windowDidLoad { [super windowDidLoad]; - [self.window setTitle:@"Keyboard/Package Info"]; + [self.window setTitle:NSLocalizedString(@"window-title-keyboard-info", nil)]; + [self.tabView setDelegate:self]; [self.detailsView setFrameLoadDelegate:(id)self]; [self.detailsView setPolicyDelegate:(id)self]; diff --git a/mac/Keyman4MacIM/Keyman4MacIM/KMInputMethodAppDelegate.m b/mac/Keyman4MacIM/Keyman4MacIM/KMInputMethodAppDelegate.m index c01f2286c7..9eed4d5897 100644 --- a/mac/Keyman4MacIM/Keyman4MacIM/KMInputMethodAppDelegate.m +++ b/mac/Keyman4MacIM/Keyman4MacIM/KMInputMethodAppDelegate.m @@ -1178,9 +1178,9 @@ CGEventRef eventTapFunction(CGEventTapProxy proxy, CGEventType type, CGEventRef - (NSAlert *)downloadInfoView { if (_downloadInfoView == nil) { _downloadInfoView = [[NSAlert alloc] init]; - [_downloadInfoView setMessageText:@"Downloading..."]; + [_downloadInfoView setMessageText:NSLocalizedString(@"message-keyboard-downloading", nil)]; [_downloadInfoView setInformativeText:@""]; - [_downloadInfoView addButtonWithTitle:@"Cancel"]; + [_downloadInfoView addButtonWithTitle:NSLocalizedString(@"button-cancel-downloading", nil)]; [_downloadInfoView setAlertStyle:NSInformationalAlertStyle]; [_downloadInfoView setAccessoryView:self.progressIndicator]; } @@ -1239,9 +1239,9 @@ CGEventRef eventTapFunction(CGEventTapProxy proxy, CGEventType type, CGEventRef } if (_connection == nil) { - [_downloadInfoView setMessageText:@"Downloading..."]; + [_downloadInfoView setMessageText:NSLocalizedString(@"message-keyboard-downloading", nil)]; NSButton *button = (NSButton *)[_downloadInfoView.buttons objectAtIndex:0]; - [button setTitle:@"Cancel"]; + [button setTitle:NSLocalizedString(@"button-cancel-downloading", nil)]; [button setTag:-1]; [self.progressIndicator setDoubleValue:0]; NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60]; @@ -1285,9 +1285,10 @@ CGEventRef eventTapFunction(CGEventTapProxy proxy, CGEventType type, CGEventRef [self.receivedData writeToFile:filePath atomically:YES]; [self unzipFile:filePath]; [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil]; - [_downloadInfoView setMessageText:@"Download Complete"]; + + [_downloadInfoView setMessageText:NSLocalizedString(@"message-keyboard-download-complete", nil)]; NSButton *button = (NSButton *)[_downloadInfoView.buttons objectAtIndex:0]; - [button setTitle:@"Done"]; + [button setTitle:NSLocalizedString(@"button-download-complete", nil)]; [button setTag:1]; [[NSNotificationCenter defaultCenter] postNotificationName:kKeymanKeyboardDownloadCompletedNotification object:self diff --git a/mac/Keyman4MacIM/Keyman4MacIM/Localizable.strings b/mac/Keyman4MacIM/Keyman4MacIM/Localizable.strings index c5c34ef628..486675c1aa 100644 --- a/mac/Keyman4MacIM/Keyman4MacIM/Localizable.strings +++ b/mac/Keyman4MacIM/Keyman4MacIM/Localizable.strings @@ -7,7 +7,7 @@ */ /* Message displayed to confirm delete of the Keyman keyboard selected by the user from the keyboard list */ -"message-confirm-delete-keyboard" = "Are you sure you want to permanently delete the keyboard '%@'?"; +"message-confirm-delete-keyboard" = "Are you sure you want to delete the keyboard '%@'?"; /* Delete keyboard confirmation info indicating that the delete action cannot be undone */ "info-cannot-undo-delete-keyboard" = "You cannot undo this action."; @@ -22,7 +22,7 @@ "message-confirm-install-keyboard" = "Install Keyman keyboard?"; /* Message displayed to confirm installation of a keyboard from the specifed .kmp file double-clicked by the user */ -"info-install-keyboard-filename" = "Do you want Keyman to install the keyboard from the file'%@'?"; +"info-install-keyboard-filename" = "Do you want Keyman to install the keyboard from the file '%@'?"; /* Button text to cancel installation of the double-clicked Keyman file */ "button-cancel-install-keyboard" = "Cancel"; @@ -31,7 +31,25 @@ "button-install-keyboard" = "Install"; /* Message displayed to inform user that .kmp file could not be read/unzipped */ -"message-keyboard-file-unreadable" = "Could not read the Keyman file."; +"message-keyboard-file-unreadable" = "Could not read the Keyman file '%@'."; /* Button text to acknowledge that .kmp file could not be read */ -"button-install-keyboard" = "Install"; +"button-keyboard-file-unreadable" = "OK"; + +/* label text to identify Keyman version */ +"version-label-text" = "Version %@"; + +/* text to identify the window that displays keyboard information */ +"window-title-keyboard-info" = "Keyboard Information"; + +/* Status text for keyboard downloading */ +"message-keyboard-downloading" = "Downloading..."; + +/* Status text for keyboard download complete */ +"message-keyboard-download-complete" = "Download complete."; + +/* Button text to cancel downloading keyboard */ +"button-cancel-downloading" = "Cancel"; + +/* Button text keyboard download complete */ +"button-download-complete" = "Done";