From 3d35db8ad87a7da2c03656c84efcb6f3b0eb0d1d Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Thu, 7 Aug 2014 12:25:16 -0700 Subject: [PATCH 1/4] Allow localization of 'All Items' and 'Categories' header text --- .../Managed Software Center/msuhtml.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/code/apps/Managed Software Center/Managed Software Center/msuhtml.py b/code/apps/Managed Software Center/Managed Software Center/msuhtml.py index 707c8fe2..cc7791c4 100644 --- a/code/apps/Managed Software Center/Managed Software Center/msuhtml.py +++ b/code/apps/Managed Software Center/Managed Software Center/msuhtml.py @@ -216,7 +216,7 @@ def build_list_page(category=None, developer=None, filter=None): '''Build page listing available optional items''' items = MunkiItems.getOptionalInstallItems() - header = u'All items' + header = NSLocalizedString(u'All items', u'AllItemsHeaderText') page_name = u'category-all.html' if category == 'all': category = None @@ -239,10 +239,11 @@ def build_list_page(category=None, developer=None, filter=None): category=category, developer=developer, filter=filter) # make HTML for Categories pop-up menu + all_categories_label = NSLocalizedString(u'All Categories', u'AllCategoriesLabel') if category: - categories_html = u'\n' + categories_html = u'\n' % all_categories_label else: - categories_html = u'\n' + categories_html = u'\n' % all_categories_label for item in sorted(category_list): if item == category: @@ -342,7 +343,7 @@ def build_list_page_items_html(category=None, developer=None, filter=None): def build_categories_page(): '''Build page showing available categories and some items in each one''' all_items = MunkiItems.getOptionalInstallItems() - header = u'Categories' + header = NSLocalizedString(u'Categories', u'CategoriesHeaderText') page_name = u'categories.html' category_list = [] for item in all_items: @@ -350,8 +351,9 @@ def build_categories_page(): category_list.append(item['category']) item_html = build_category_items_html() - - categories_html = u'\n' + + all_categories_label = NSLocalizedString(u'All Categories', u'AllCategoriesLabel') + categories_html = u'\n' % all_categories_label for item in sorted(category_list): categories_html += u'\n' % item From 9d4c21a1c20194e0577662f81bc118881fa7af44 Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Thu, 7 Aug 2014 12:31:56 -0700 Subject: [PATCH 2/4] Support localization of status messages passed to MSC.app/MunkiStatus.app from managedsoftwareupdate. --- .../Managed Software Center/MSUStatusController.py | 4 ++-- .../apps/MunkiStatus/MunkiStatus/MSUStatusWindowController.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/apps/Managed Software Center/Managed Software Center/MSUStatusController.py b/code/apps/Managed Software Center/Managed Software Center/MSUStatusController.py index 2a4f7d64..73348812 100644 --- a/code/apps/Managed Software Center/Managed Software Center/MSUStatusController.py +++ b/code/apps/Managed Software Center/Managed Software Center/MSUStatusController.py @@ -222,7 +222,7 @@ class MSUStatusController(NSObject): def setMessage_(self, messageText): '''Display main status message''' - self._status_message = messageText + self._status_message = NSLocalizedString(messageText, None) document = self.statusWindowController.webView.mainFrameDocument() if document: spinner = document.getElementById_('updates-progress-spinner') @@ -236,7 +236,7 @@ class MSUStatusController(NSObject): def setDetail_(self, detailText): '''Display status detail''' - self._status_detail = detailText + self._status_detail = NSLocalizedString(detailText, None) document = self.statusWindowController.webView.mainFrameDocument() if document: spinner = document.getElementById_('updates-progress-spinner') diff --git a/code/apps/MunkiStatus/MunkiStatus/MSUStatusWindowController.py b/code/apps/MunkiStatus/MunkiStatus/MSUStatusWindowController.py index 080ab80d..fe8c34e5 100644 --- a/code/apps/MunkiStatus/MunkiStatus/MSUStatusWindowController.py +++ b/code/apps/MunkiStatus/MunkiStatus/MSUStatusWindowController.py @@ -290,10 +290,10 @@ class MSUStatusWindowController(NSObject): self.window, self, self.restartAlertDidEnd_returnCode_contextInfo_, nil) def setMessage_(self, messageText): - self.messageFld.setStringValue_(messageText) + self.messageFld.setStringValue_(NSLocalizedString(messageText, None)) def setDetail_(self, detailText): - self.detailFld.setStringValue_(detailText) + self.detailFld.setStringValue_(NSLocalizedString(detailText, None)) def getStopBtnState(self): return self.stopBtnState From 617115649ea86e15777814d204ef74338d767181 Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Thu, 7 Aug 2014 14:32:09 -0700 Subject: [PATCH 3/4] Change all calls to NSAlert alertWithMessageText:defaultButton:alternateButton:otherButton:informativeTextWithFormat: to reflect the fact that informativeTextWithFormat: requires a _format_ string. Ignoring this was triggering errors when non-ASCII localized text was used for the informativeText. --- .../AlertController.py | 33 +++++++++---------- .../MSUMainWindowController.py | 4 +-- .../MSUStatusController.py | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/code/apps/Managed Software Center/Managed Software Center/AlertController.py b/code/apps/Managed Software Center/Managed Software Center/AlertController.py index cb17988c..59f74b24 100644 --- a/code/apps/Managed Software Center/Managed Software Center/AlertController.py +++ b/code/apps/Managed Software Center/Managed Software Center/AlertController.py @@ -88,7 +88,7 @@ class AlertController(NSObject): self._force_warning_btns[NSAlertDefaultReturn], self._force_warning_btns[NSAlertAlternateReturn], nil, - infoText) + u"%@", infoText) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.window, self, self.forceLogoutWarningDidEnd_returnCode_contextInfo_, nil) @@ -111,7 +111,7 @@ class AlertController(NSObject): NSLocalizedString(u"OK", u"OK button title"), nil, nil, - NSLocalizedString( + u"%@", NSLocalizedString( (u"There are additional pending updates to install or remove."), u"Additional Pending Updates detail")) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( @@ -133,7 +133,7 @@ class AlertController(NSObject): NSLocalizedString(u"Log out and update", u"Log out and Update button text"), NSLocalizedString(u"Cancel", u"Cancel button title"), nil, - NSLocalizedString( + u"%@", NSLocalizedString( (u"A restart is required after updating. Please be patient " "as there may be a short delay at the login window. Log " "out and update now?"), u"Restart Required detail")) @@ -146,7 +146,7 @@ class AlertController(NSObject): NSLocalizedString(u"Log out and update", u"Log out and Update button text"), NSLocalizedString(u"Cancel", u"Cancel button title"), nil, - NSLocalizedString( + u"%@", NSLocalizedString( (u"A logout is required before updating. Please be patient " "as there may be a short delay at the login window. Log " "out and update now?"), u"Logout Required detail")) @@ -188,7 +188,7 @@ class AlertController(NSObject): NSLocalizedString(u"Cancel", u"Cancel button title"), nil, nil, - NSLocalizedString( + u"%@", NSLocalizedString( (u"There are other users logged into this computer.\n" "Updating now could cause other users to lose their " "work.\n\nPlease try again later after the other users " @@ -223,31 +223,30 @@ class AlertController(NSObject): if item['user'] != current_user] my_apps = [item['display_name'] for item in running_apps if item['user'] == current_user] + msulog.log("MSC", "conflicting_apps", ','.join(other_users_apps + my_apps)) if other_users_apps: + detailText = NSLocalizedString( + (u"Other logged in users are using the following applications. " + "Try updating later when they are no longer in use:\n\n%s"), + u"Other Users Blocking Apps Running detail") alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString( u"Applications in use by others", u"Other Users Blocking Apps Running title"), NSLocalizedString(u"OK", u'OKButtonText'), nil, nil, - NSLocalizedString( - (u"Other logged in users are using the following applications. " - "Try updating later when they are no longer in use:\n\n%s"), - u"Other Users Blocking Apps Running detail") - % '\n'.join(set(other_users_apps))) + u"%@", detailText % u'\n'.join(set(other_users_apps))) else: + detailText = NSLocalizedString((u"You must quit the following applications before " + "proceeding with installation or removal:\n\n%s"), + u"Blocking Apps Running detail") alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString( u"Conflicting applications running", u"Blocking Apps Running title"), NSLocalizedString(u"OK", u"OK button title"), nil, nil, - NSLocalizedString( - (u"You must quit the following applications before " - "proceeding with installation or removal:\n\n%s"), - u"Blocking Apps Running detail") - % '\n'.join(set(my_apps))) - msulog.log("MSC", "conflicting_apps", ','.join(other_users_apps + my_apps)) + u"%@", detailText % u'\n'.join(set(my_apps))) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.window, self, self.blockingAppsRunningAlertDidEnd_returnCode_contextInfo_, @@ -329,7 +328,7 @@ class AlertController(NSObject): NSLocalizedString(u"Continue", u"Continue button text"), NSLocalizedString(u"Cancel", u"Cancel button title"), nil, - NSLocalizedString( + u"%@", NSLocalizedString( (u"For best results, you should connect your computer to a " "power source before updating. Are you sure you want to " "continue the update?"), u"No Power Source Warning detail")) diff --git a/code/apps/Managed Software Center/Managed Software Center/MSUMainWindowController.py b/code/apps/Managed Software Center/Managed Software Center/MSUMainWindowController.py index b3f7481a..549f629c 100644 --- a/code/apps/Managed Software Center/Managed Software Center/MSUMainWindowController.py +++ b/code/apps/Managed Software Center/Managed Software Center/MSUMainWindowController.py @@ -113,7 +113,7 @@ class MSUMainWindowController(NSWindowController): NSLocalizedString(u"Quit", u"Quit button title"), nil, NSLocalizedString(u"Update now", u"Update Now button title"), - alertDetail) + u"%@", alertDetail) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.window(), self, self.updateAlertDidEnd_returnCode_contextInfo_, objc.nil) @@ -217,7 +217,7 @@ class MSUMainWindowController(NSWindowController): # show the alert sheet self.window().makeKeyAndOrderFront_(self) alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( - alertMessageText, OKButtonTitle, nil, nil, detailText) + alertMessageText, OKButtonTitle, nil, nil, u"%@", detailText) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.window(), self, self.munkiSessionErrorAlertDidEnd_returnCode_contextInfo_, nil) diff --git a/code/apps/Managed Software Center/Managed Software Center/MSUStatusController.py b/code/apps/Managed Software Center/Managed Software Center/MSUStatusController.py index 73348812..efea8e2d 100644 --- a/code/apps/Managed Software Center/Managed Software Center/MSUStatusController.py +++ b/code/apps/Managed Software Center/Managed Software Center/MSUStatusController.py @@ -206,7 +206,7 @@ class MSUStatusController(NSObject): NSLocalizedString(u"Restart", u"Restart button title"), nil, nil, - NSLocalizedString( + u"%@", NSLocalizedString( u"Software installed or removed requires a restart. You will " "have a chance to save open documents.", u"Restart Required alert detail")) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( From 9b023b1354a9091fe6da210bbaed17acd0695efb Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Thu, 7 Aug 2014 15:07:46 -0700 Subject: [PATCH 4/4] Make toolbar button labels wider --- .../Managed Software Center/en.lproj/MainMenu.xib | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/apps/Managed Software Center/Managed Software Center/en.lproj/MainMenu.xib b/code/apps/Managed Software Center/Managed Software Center/en.lproj/MainMenu.xib index a339d350..8a2784ea 100644 --- a/code/apps/Managed Software Center/Managed Software Center/en.lproj/MainMenu.xib +++ b/code/apps/Managed Software Center/Managed Software Center/en.lproj/MainMenu.xib @@ -1,5 +1,5 @@ - + @@ -239,7 +239,7 @@