From e0c22ecc768dfad81bfb97ac59aeaacc1e937a6c Mon Sep 17 00:00:00 2001 From: Bob Swift Date: Thu, 6 Dec 2018 13:59:52 -0700 Subject: [PATCH 1/5] Remove incorrect text extraction --- picard/ui/options/general.py | 2 +- picard/ui/options/interface.py | 4 ++-- picard/util/checkupdate.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/picard/ui/options/general.py b/picard/ui/options/general.py index 60f8ae60f..86a6f25b5 100644 --- a/picard/ui/options/general.py +++ b/picard/ui/options/general.py @@ -76,7 +76,7 @@ class GeneralOptionsPage(OptionsPage): self.ui.check_for_updates.setChecked(config.setting["check_for_updates"]) self.ui.update_level.clear() for level, description in PROGRAM_UPDATE_LEVELS.items(): - self.ui.update_level.addItem(_(description['title']), level) + self.ui.update_level.addItem(description['title'], level) self.ui.update_level.setCurrentIndex(self.ui.update_level.findData(config.setting["update_level"])) self.ui.update_check_days.setValue(config.setting["update_check_days"]) else: diff --git a/picard/ui/options/interface.py b/picard/ui/options/interface.py index e6d9f6a9b..5aa815c37 100644 --- a/picard/ui/options/interface.py +++ b/picard/ui/options/interface.py @@ -218,7 +218,7 @@ class InterfaceOptionsPage(OptionsPage): list_item = ToolbarListItem(action) list_item.setToolTip(_('Drag and Drop to re-order')) if action in self.TOOLBAR_BUTTONS: - list_item.setText(_(self.TOOLBAR_BUTTONS[action]['label'])) + list_item.setText(self.TOOLBAR_BUTTONS[action]['label']) list_item.setIcon(icontheme.lookup(self._get_icon_from_name(action), icontheme.ICON_SIZE_MENU)) else: list_item.setText(self.SEPARATOR) @@ -287,7 +287,7 @@ class AddActionDialog(QtWidgets.QDialog): layout = QtWidgets.QVBoxLayout(self) - self.action_list = sorted([[_(self.parent().TOOLBAR_BUTTONS[action]['label']), action] + self.action_list = sorted([[self.parent().TOOLBAR_BUTTONS[action]['label'], action] for action in action_list]) self.combo_box = QtWidgets.QComboBox(self) diff --git a/picard/util/checkupdate.py b/picard/util/checkupdate.py index 92bd10303..518e2d026 100644 --- a/picard/util/checkupdate.py +++ b/picard/util/checkupdate.py @@ -149,7 +149,7 @@ class UpdateCheckManager(QtCore.QObject): _("Picard Update"), _("There is no update currently available for your subscribed update level: {update_level}\n\n" "Your version: {picard_old_version}\n").format( - update_level=_(PROGRAM_UPDATE_LEVELS[self._update_level]['title']) if self._update_level in PROGRAM_UPDATE_LEVELS else _('unknown'), + update_level=PROGRAM_UPDATE_LEVELS[self._update_level]['title'] if self._update_level in PROGRAM_UPDATE_LEVELS else _('unknown'), picard_old_version=PICARD_FANCY_VERSION_STR, ), QMessageBox.Ok, QMessageBox.Ok From fb74ecedacbe9849e9e5b5523666ca561e068cf2 Mon Sep 17 00:00:00 2001 From: Bob Swift Date: Thu, 6 Dec 2018 14:39:57 -0700 Subject: [PATCH 2/5] Use temporary variables for translation --- picard/ui/options/general.py | 3 ++- picard/ui/options/interface.py | 11 ++++++++--- picard/util/checkupdate.py | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/picard/ui/options/general.py b/picard/ui/options/general.py index 86a6f25b5..2f6fbe484 100644 --- a/picard/ui/options/general.py +++ b/picard/ui/options/general.py @@ -76,7 +76,8 @@ class GeneralOptionsPage(OptionsPage): self.ui.check_for_updates.setChecked(config.setting["check_for_updates"]) self.ui.update_level.clear() for level, description in PROGRAM_UPDATE_LEVELS.items(): - self.ui.update_level.addItem(description['title'], level) + temp_text = description['title'] + self.ui.update_level.addItem(_(temp_text), level) self.ui.update_level.setCurrentIndex(self.ui.update_level.findData(config.setting["update_level"])) self.ui.update_check_days.setValue(config.setting["update_check_days"]) else: diff --git a/picard/ui/options/interface.py b/picard/ui/options/interface.py index 5aa815c37..56b38ea7e 100644 --- a/picard/ui/options/interface.py +++ b/picard/ui/options/interface.py @@ -218,7 +218,8 @@ class InterfaceOptionsPage(OptionsPage): list_item = ToolbarListItem(action) list_item.setToolTip(_('Drag and Drop to re-order')) if action in self.TOOLBAR_BUTTONS: - list_item.setText(self.TOOLBAR_BUTTONS[action]['label']) + temp_text = self.TOOLBAR_BUTTONS[action]['label'] + list_item.setText(_(temp_text)) list_item.setIcon(icontheme.lookup(self._get_icon_from_name(action), icontheme.ICON_SIZE_MENU)) else: list_item.setText(self.SEPARATOR) @@ -287,8 +288,12 @@ class AddActionDialog(QtWidgets.QDialog): layout = QtWidgets.QVBoxLayout(self) - self.action_list = sorted([[self.parent().TOOLBAR_BUTTONS[action]['label'], action] - for action in action_list]) + temp_list = [] + for action in action_list: + temp_text = self.parent().TOOLBAR_BUTTONS[action]['label'] + temp_list.append([_(temp_text), action]) + + self.action_list = sorted(temp_list) self.combo_box = QtWidgets.QComboBox(self) self.combo_box.addItems([label for label, action in self.action_list]) diff --git a/picard/util/checkupdate.py b/picard/util/checkupdate.py index 518e2d026..8d2225427 100644 --- a/picard/util/checkupdate.py +++ b/picard/util/checkupdate.py @@ -144,12 +144,13 @@ class UpdateCheckManager(QtCore.QObject): webbrowser2.open(self._available_versions[key]['urls']['download']) else: if self._show_always: + update_level_text = PROGRAM_UPDATE_LEVELS[self._update_level]['title'] if self._update_level in PROGRAM_UPDATE_LEVELS else 'unknown' QMessageBox.information( self._parent, _("Picard Update"), _("There is no update currently available for your subscribed update level: {update_level}\n\n" "Your version: {picard_old_version}\n").format( - update_level=PROGRAM_UPDATE_LEVELS[self._update_level]['title'] if self._update_level in PROGRAM_UPDATE_LEVELS else _('unknown'), + update_level=_(update_level_text), picard_old_version=PICARD_FANCY_VERSION_STR, ), QMessageBox.Ok, QMessageBox.Ok From 0e4d382b4cc528a0e892c257e6433334064d3cb3 Mon Sep 17 00:00:00 2001 From: Bob Swift Date: Thu, 6 Dec 2018 16:16:49 -0700 Subject: [PATCH 3/5] Mark temporary workaround with TODO and comment original code --- picard/ui/options/general.py | 6 ++++-- picard/ui/options/interface.py | 18 +++++++++++------- picard/util/checkupdate.py | 6 ++++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/picard/ui/options/general.py b/picard/ui/options/general.py index 2f6fbe484..e9ea3d665 100644 --- a/picard/ui/options/general.py +++ b/picard/ui/options/general.py @@ -76,8 +76,10 @@ class GeneralOptionsPage(OptionsPage): self.ui.check_for_updates.setChecked(config.setting["check_for_updates"]) self.ui.update_level.clear() for level, description in PROGRAM_UPDATE_LEVELS.items(): - temp_text = description['title'] - self.ui.update_level.addItem(_(temp_text), level) + # TODO: Remove temporary workaround once https://github.com/python-babel/babel/issues/415 has been resolved. + babel_415_workaround = description['title'] + self.ui.update_level.addItem(_(babel_415_workaround), level) + #self.ui.update_level.addItem(description['title'], level) self.ui.update_level.setCurrentIndex(self.ui.update_level.findData(config.setting["update_level"])) self.ui.update_check_days.setValue(config.setting["update_check_days"]) else: diff --git a/picard/ui/options/interface.py b/picard/ui/options/interface.py index 56b38ea7e..4d99c2dcf 100644 --- a/picard/ui/options/interface.py +++ b/picard/ui/options/interface.py @@ -218,8 +218,10 @@ class InterfaceOptionsPage(OptionsPage): list_item = ToolbarListItem(action) list_item.setToolTip(_('Drag and Drop to re-order')) if action in self.TOOLBAR_BUTTONS: - temp_text = self.TOOLBAR_BUTTONS[action]['label'] - list_item.setText(_(temp_text)) + # TODO: Remove temporary workaround once https://github.com/python-babel/babel/issues/415 has been resolved. + babel_415_workaround = self.TOOLBAR_BUTTONS[action]['label'] + list_item.setText(_(babel_415_workaround)) + #list_item.setText(self.TOOLBAR_BUTTONS[action]['label']) list_item.setIcon(icontheme.lookup(self._get_icon_from_name(action), icontheme.ICON_SIZE_MENU)) else: list_item.setText(self.SEPARATOR) @@ -288,12 +290,14 @@ class AddActionDialog(QtWidgets.QDialog): layout = QtWidgets.QVBoxLayout(self) - temp_list = [] + # TODO: Remove temporary workaround once https://github.com/python-babel/babel/issues/415 has been resolved. + babel_415_workaround_list = [] for action in action_list: - temp_text = self.parent().TOOLBAR_BUTTONS[action]['label'] - temp_list.append([_(temp_text), action]) - - self.action_list = sorted(temp_list) + babel_415_workaround = self.parent().TOOLBAR_BUTTONS[action]['label'] + temp_list.append([_(babel_415_workaround), action]) + self.action_list = sorted(babel_415_workaround_list) + #self.action_list = sorted([[self.parent().TOOLBAR_BUTTONS[action]['label'], action] + # for action in action_list]) self.combo_box = QtWidgets.QComboBox(self) self.combo_box.addItems([label for label, action in self.action_list]) diff --git a/picard/util/checkupdate.py b/picard/util/checkupdate.py index 8d2225427..e84329fe3 100644 --- a/picard/util/checkupdate.py +++ b/picard/util/checkupdate.py @@ -144,13 +144,15 @@ class UpdateCheckManager(QtCore.QObject): webbrowser2.open(self._available_versions[key]['urls']['download']) else: if self._show_always: - update_level_text = PROGRAM_UPDATE_LEVELS[self._update_level]['title'] if self._update_level in PROGRAM_UPDATE_LEVELS else 'unknown' + # TODO: Remove temporary workaround once https://github.com/python-babel/babel/issues/415 has been resolved. + babel_415_workaround = PROGRAM_UPDATE_LEVELS[self._update_level]['title'] if self._update_level in PROGRAM_UPDATE_LEVELS else 'unknown' QMessageBox.information( self._parent, _("Picard Update"), _("There is no update currently available for your subscribed update level: {update_level}\n\n" "Your version: {picard_old_version}\n").format( - update_level=_(update_level_text), + update_level=_(babel_415_workaround), + #update_level=PROGRAM_UPDATE_LEVELS[self._update_level]['title'] if self._update_level in PROGRAM_UPDATE_LEVELS else _('unknown'), picard_old_version=PICARD_FANCY_VERSION_STR, ), QMessageBox.Ok, QMessageBox.Ok From 19c8af903dcefefa4653b9d258b9f5a7857972ba Mon Sep 17 00:00:00 2001 From: Bob Swift Date: Fri, 7 Dec 2018 09:02:13 -0700 Subject: [PATCH 4/5] Revise to avoid using temporary workaround. --- picard/util/checkupdate.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/picard/util/checkupdate.py b/picard/util/checkupdate.py index e84329fe3..7ebe49eca 100644 --- a/picard/util/checkupdate.py +++ b/picard/util/checkupdate.py @@ -144,15 +144,16 @@ class UpdateCheckManager(QtCore.QObject): webbrowser2.open(self._available_versions[key]['urls']['download']) else: if self._show_always: - # TODO: Remove temporary workaround once https://github.com/python-babel/babel/issues/415 has been resolved. - babel_415_workaround = PROGRAM_UPDATE_LEVELS[self._update_level]['title'] if self._update_level in PROGRAM_UPDATE_LEVELS else 'unknown' + if self._update_level in PROGRAM_UPDATE_LEVELS: + update_level = PROGRAM_UPDATE_LEVELS[self._update_level]['title'] + else: + update_level = N_('unknown') QMessageBox.information( self._parent, _("Picard Update"), _("There is no update currently available for your subscribed update level: {update_level}\n\n" "Your version: {picard_old_version}\n").format( - update_level=_(babel_415_workaround), - #update_level=PROGRAM_UPDATE_LEVELS[self._update_level]['title'] if self._update_level in PROGRAM_UPDATE_LEVELS else _('unknown'), + update_level=_(update_level), picard_old_version=PICARD_FANCY_VERSION_STR, ), QMessageBox.Ok, QMessageBox.Ok From c87bc345312ed9a0c26b6bcd485bd638f6ed2aa5 Mon Sep 17 00:00:00 2001 From: Bob Swift Date: Fri, 7 Dec 2018 10:19:19 -0700 Subject: [PATCH 5/5] Remove original commented out code. --- picard/ui/options/general.py | 1 - picard/ui/options/interface.py | 3 --- 2 files changed, 4 deletions(-) diff --git a/picard/ui/options/general.py b/picard/ui/options/general.py index e9ea3d665..83623af6b 100644 --- a/picard/ui/options/general.py +++ b/picard/ui/options/general.py @@ -79,7 +79,6 @@ class GeneralOptionsPage(OptionsPage): # TODO: Remove temporary workaround once https://github.com/python-babel/babel/issues/415 has been resolved. babel_415_workaround = description['title'] self.ui.update_level.addItem(_(babel_415_workaround), level) - #self.ui.update_level.addItem(description['title'], level) self.ui.update_level.setCurrentIndex(self.ui.update_level.findData(config.setting["update_level"])) self.ui.update_check_days.setValue(config.setting["update_check_days"]) else: diff --git a/picard/ui/options/interface.py b/picard/ui/options/interface.py index 4d99c2dcf..3da29c800 100644 --- a/picard/ui/options/interface.py +++ b/picard/ui/options/interface.py @@ -221,7 +221,6 @@ class InterfaceOptionsPage(OptionsPage): # TODO: Remove temporary workaround once https://github.com/python-babel/babel/issues/415 has been resolved. babel_415_workaround = self.TOOLBAR_BUTTONS[action]['label'] list_item.setText(_(babel_415_workaround)) - #list_item.setText(self.TOOLBAR_BUTTONS[action]['label']) list_item.setIcon(icontheme.lookup(self._get_icon_from_name(action), icontheme.ICON_SIZE_MENU)) else: list_item.setText(self.SEPARATOR) @@ -296,8 +295,6 @@ class AddActionDialog(QtWidgets.QDialog): babel_415_workaround = self.parent().TOOLBAR_BUTTONS[action]['label'] temp_list.append([_(babel_415_workaround), action]) self.action_list = sorted(babel_415_workaround_list) - #self.action_list = sorted([[self.parent().TOOLBAR_BUTTONS[action]['label'], action] - # for action in action_list]) self.combo_box = QtWidgets.QComboBox(self) self.combo_box.addItems([label for label, action in self.action_list])