externalize strings for alerts and download status

This commit is contained in:
Shawn Schantz 2021-10-14 14:28:45 +07:00
parent 163446be06
commit 0b16eeff80
5 changed files with 39 additions and 17 deletions

View file

@ -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];

View file

@ -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

View file

@ -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<WebFrameLoadDelegate>)self];
[self.detailsView setPolicyDelegate:(id<WebPolicyDelegate>)self];

View file

@ -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

View file

@ -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";