From 6ea889b974382a6c97ca9409939d6da48d6961d9 Mon Sep 17 00:00:00 2001 From: Chris Witterholt Date: Mon, 18 Mar 2024 06:13:26 +0000 Subject: [PATCH] Fix missing translations --- openlp/plugins/songs/forms/editsongdialog.py | 8 +++--- openlp/plugins/songs/forms/editsongform.py | 2 +- .../songs/forms/songmaintenancedialog.py | 14 +++++------ openlp/plugins/songs/lib/__init__.py | 2 +- .../plugins/songs/lib/importers/datasoul.py | 2 +- .../plugins/songs/lib/importers/dreambeam.py | 8 +++--- .../plugins/songs/lib/importers/easyslides.py | 6 ++--- .../songs/lib/importers/foilpresenter.py | 2 +- .../songs/lib/importers/liveworship.py | 2 +- .../plugins/songs/lib/importers/openlyrics.py | 2 +- .../plugins/songs/lib/importers/opensong.py | 2 +- .../songs/lib/importers/powerpraise.py | 4 +-- .../songs/lib/importers/propresenter.py | 4 +-- .../plugins/songs/lib/importers/songimport.py | 6 ++--- openlp/plugins/songs/lib/mediaitem.py | 10 ++++---- openlp/plugins/songs/lib/ui.py | 25 ++++++++++--------- resources/forms/songmaintenance.ui | 9 +++---- .../songs/test_openlyricsimport.py | 4 +-- 18 files changed, 55 insertions(+), 57 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index cba8bc780..00bad7007 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -309,15 +309,15 @@ class Ui_EditSongDialog(object): self.verse_delete_button.setText(UiStrings().Delete) self.song_tab_widget.setTabText(self.song_tab_widget.indexOf(self.lyrics_tab), translate('SongsPlugin.EditSongForm', 'Title && Lyrics')) - self.authors_group_box.setTitle(SongStrings.Authors) + self.authors_group_box.setTitle(SongStrings().Authors) self.author_add_button.setText(translate('SongsPlugin.EditSongForm', '&Add to Song')) self.author_edit_button.setText(translate('SongsPlugin.EditSongForm', '&Edit Author Type')) self.author_remove_button.setText(translate('SongsPlugin.EditSongForm', '&Remove')) self.maintenance_button.setText(translate('SongsPlugin.EditSongForm', '&Manage Authors, Topics, Songbooks')) - self.topics_group_box.setTitle(SongStrings.Topics) + self.topics_group_box.setTitle(SongStrings().Topics) self.topic_add_button.setText(translate('SongsPlugin.EditSongForm', 'A&dd to Song')) self.topic_remove_button.setText(translate('SongsPlugin.EditSongForm', 'R&emove')) - self.songbook_group_box.setTitle(SongStrings.SongBooks) + self.songbook_group_box.setTitle(SongStrings().SongBooks) self.songbook_add_button.setText(translate('SongsPlugin.EditSongForm', 'Add &to Song')) self.songbook_remove_button.setText(translate('SongsPlugin.EditSongForm', 'Re&move')) self.song_tab_widget.setTabText(self.song_tab_widget.indexOf(self.authors_tab), @@ -325,7 +325,7 @@ class Ui_EditSongDialog(object): self.theme_group_box.setTitle(UiStrings().Theme) self.theme_add_button.setText(translate('SongsPlugin.EditSongForm', 'New &Theme')) self.rights_group_box.setTitle(translate('SongsPlugin.EditSongForm', 'Copyright Information')) - self.copyright_insert_button.setText(SongStrings.CopyrightSymbol) + self.copyright_insert_button.setText(SongStrings().CopyrightSymbol) self.ccli_label.setText(UiStrings().CCLISongNumberLabel) self.comments_group_box.setTitle(translate('SongsPlugin.EditSongForm', 'Comments')) self.song_tab_widget.setTabText(self.song_tab_widget.indexOf(self.theme_tab), diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index a25f570c1..cc4bc24ca 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -911,7 +911,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties): """ text = self.copyright_edit.text() pos = self.copyright_edit.cursorPosition() - sign = SongStrings.CopyrightSymbol + sign = SongStrings().CopyrightSymbol text = text[:pos] + sign + text[pos:] self.copyright_edit.setText(text) self.copyright_edit.setFocus() diff --git a/openlp/plugins/songs/forms/songmaintenancedialog.py b/openlp/plugins/songs/forms/songmaintenancedialog.py index 1dd185b7c..7cd287554 100644 --- a/openlp/plugins/songs/forms/songmaintenancedialog.py +++ b/openlp/plugins/songs/forms/songmaintenancedialog.py @@ -141,10 +141,10 @@ class Ui_SongMaintenanceDialog(object): """ Translate the UI on the fly. """ - song_maintenance_dialog.setWindowTitle(SongStrings.SongMaintenance) - self.authors_list_item.setText(SongStrings.Authors) - self.topics_list_item.setText(SongStrings.Topics) - self.books_list_item.setText(SongStrings.SongBooks) + song_maintenance_dialog.setWindowTitle(SongStrings().SongMaintenance) + self.authors_list_item.setText(SongStrings().Authors) + self.topics_list_item.setText(SongStrings().Topics) + self.books_list_item.setText(SongStrings().SongBooks) self.add_author_button.setText(UiStrings().Add) self.edit_author_button.setText(UiStrings().Edit) self.delete_author_button.setText(UiStrings().Delete) @@ -154,7 +154,7 @@ class Ui_SongMaintenanceDialog(object): self.add_book_button.setText(UiStrings().Add) self.edit_book_button.setText(UiStrings().Edit) self.delete_book_button.setText(UiStrings().Delete) - type_list_width = max(self.fontMetrics().width(SongStrings.Authors), - self.fontMetrics().width(SongStrings.Topics), - self.fontMetrics().width(SongStrings.SongBooks)) + type_list_width = max(self.fontMetrics().width(SongStrings().Authors), + self.fontMetrics().width(SongStrings().Topics), + self.fontMetrics().width(SongStrings().SongBooks)) self.type_list_widget.setFixedWidth(type_list_width + self.type_list_widget.iconSize().width() + 32) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 9df5ab4eb..854f564cc 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -384,7 +384,7 @@ def clean_song(manager, song): song.search_lyrics = ' '.join([clean_string(remove_tags(verse[1], True)) for verse in verses]) # The song does not have any author, add one. if not song.authors_songs: - name = SongStrings.AuthorUnknown + name = SongStrings().AuthorUnknown author = manager.get_object_filtered(Author, Author.display_name == name) if author is None: author = Author(display_name=name, last_name='', first_name='') diff --git a/openlp/plugins/songs/lib/importers/datasoul.py b/openlp/plugins/songs/lib/importers/datasoul.py index d42d22667..6e2abf4fd 100644 --- a/openlp/plugins/songs/lib/importers/datasoul.py +++ b/openlp/plugins/songs/lib/importers/datasoul.py @@ -56,7 +56,7 @@ class DatasoulImport(SongImport): tree = objectify.parse(str(file_path), parser) except etree.XMLSyntaxError: log.exception('XML syntax error in file {name}'.format(name=file_path)) - self.log_error(file_path, SongStrings.XMLSyntaxError) + self.log_error(file_path, SongStrings().XMLSyntaxError) continue song_xml = tree.getroot() if song_xml.tag != 'Song': diff --git a/openlp/plugins/songs/lib/importers/dreambeam.py b/openlp/plugins/songs/lib/importers/dreambeam.py index 8794e9ede..91751a115 100644 --- a/openlp/plugins/songs/lib/importers/dreambeam.py +++ b/openlp/plugins/songs/lib/importers/dreambeam.py @@ -93,16 +93,16 @@ class DreamBeamImport(SongImport): parsed_file = etree.parse(xml_file, parser) except etree.XMLSyntaxError: log.exception('XML syntax error in file {name}'.format(name=file_path)) - self.log_error(file_path, SongStrings.XMLSyntaxError) + self.log_error(file_path, SongStrings().XMLSyntaxError) continue except UnicodeDecodeError: log.exception('Unreadable characters in {name}'.format(name=file_path)) - self.log_error(file_path, SongStrings.XMLSyntaxError) + self.log_error(file_path, SongStrings().XMLSyntaxError) continue file_str = etree.tostring(parsed_file) if not file_str: log.exception('Could not find XML in file {name}'.format(name=file_path)) - self.log_error(file_path, SongStrings.XMLSyntaxError) + self.log_error(file_path, SongStrings().XMLSyntaxError) continue xml = file_str.decode() song_xml = objectify.fromstring(xml) @@ -151,7 +151,7 @@ class DreamBeamImport(SongImport): author_copyright = song_xml.Text2.Text.text if author_copyright: author_copyright = str(author_copyright) - if author_copyright.find(SongStrings.CopyrightSymbol) >= 0: + if author_copyright.find(SongStrings().CopyrightSymbol) >= 0: self.add_copyright(author_copyright) else: self.parse_author(author_copyright) diff --git a/openlp/plugins/songs/lib/importers/easyslides.py b/openlp/plugins/songs/lib/importers/easyslides.py index b1a633c52..62743bd2a 100644 --- a/openlp/plugins/songs/lib/importers/easyslides.py +++ b/openlp/plugins/songs/lib/importers/easyslides.py @@ -54,16 +54,16 @@ class EasySlidesImport(SongImport): parsed_file = etree.parse(xml_file, parser) except etree.XMLSyntaxError: log.exception('XML syntax error in file {name}'.format(name=self.import_source)) - self.log_error(self.import_source, SongStrings.XMLSyntaxError) + self.log_error(self.import_source, SongStrings().XMLSyntaxError) return except UnicodeDecodeError: log.exception('Unreadable characters in {name}'.format(name=self.import_source)) - self.log_error(self.import_source, SongStrings.XMLSyntaxError) + self.log_error(self.import_source, SongStrings().XMLSyntaxError) return file_str = etree.tostring(parsed_file) if not file_str: log.exception('Could not find XML in file {name}'.format(name=self.import_source)) - self.log_error(self.import_source, SongStrings.XMLSyntaxError) + self.log_error(self.import_source, SongStrings().XMLSyntaxError) return xml = file_str.decode() song_xml = objectify.fromstring(xml) diff --git a/openlp/plugins/songs/lib/importers/foilpresenter.py b/openlp/plugins/songs/lib/importers/foilpresenter.py index 361d08f01..d4efb18bc 100644 --- a/openlp/plugins/songs/lib/importers/foilpresenter.py +++ b/openlp/plugins/songs/lib/importers/foilpresenter.py @@ -125,7 +125,7 @@ class FoilPresenterImport(SongImport): xml = etree.tostring(parsed_file).decode() self.foil_presenter.xml_to_song(xml) except etree.XMLSyntaxError: - self.log_error(file_path, SongStrings.XMLSyntaxError) + self.log_error(file_path, SongStrings().XMLSyntaxError) log.exception('XML syntax error in file {path}'.format(path=file_path)) except AttributeError: self.log_error(file_path, translate('SongsPlugin.FoilPresenterSongImport', diff --git a/openlp/plugins/songs/lib/importers/liveworship.py b/openlp/plugins/songs/lib/importers/liveworship.py index 892f64326..9848734af 100644 --- a/openlp/plugins/songs/lib/importers/liveworship.py +++ b/openlp/plugins/songs/lib/importers/liveworship.py @@ -72,7 +72,7 @@ class LiveWorshipImport(SongImport): try: self.root = etree.fromstring(xml_content, parser) except etree.XMLSyntaxError: - self.log_error(self.dump_file, SongStrings.XMLSyntaxError) + self.log_error(self.dump_file, SongStrings().XMLSyntaxError) log.exception('XML syntax error in file {path}'.format(path=str(self.dump_file))) def extract_songs(self): diff --git a/openlp/plugins/songs/lib/importers/openlyrics.py b/openlp/plugins/songs/lib/importers/openlyrics.py index 15653e05b..44256319f 100644 --- a/openlp/plugins/songs/lib/importers/openlyrics.py +++ b/openlp/plugins/songs/lib/importers/openlyrics.py @@ -73,7 +73,7 @@ class OpenLyricsImport(SongImport): self.open_lyrics.xml_to_song(xml) except etree.XMLSyntaxError: log.exception('XML syntax error in file {path}'.format(path=file_path)) - self.log_error(file_path, SongStrings.XMLSyntaxError) + self.log_error(file_path, SongStrings().XMLSyntaxError) except OpenLyricsError as exception: log.exception('OpenLyricsException {error:d} in file {name}: {text}'.format(error=exception.type, name=file_path, diff --git a/openlp/plugins/songs/lib/importers/opensong.py b/openlp/plugins/songs/lib/importers/opensong.py index 91ffb8319..6af01a35c 100644 --- a/openlp/plugins/songs/lib/importers/opensong.py +++ b/openlp/plugins/songs/lib/importers/opensong.py @@ -129,7 +129,7 @@ class OpenSongImport(SongImport): try: tree = objectify.parse(file) except (etree.Error, etree.LxmlError): - self.log_error(file.name, SongStrings.XMLSyntaxError) + self.log_error(file.name, SongStrings().XMLSyntaxError) log.exception('Error parsing XML') return root = tree.getroot() diff --git a/openlp/plugins/songs/lib/importers/powerpraise.py b/openlp/plugins/songs/lib/importers/powerpraise.py index 7392b3865..baf58abe7 100644 --- a/openlp/plugins/songs/lib/importers/powerpraise.py +++ b/openlp/plugins/songs/lib/importers/powerpraise.py @@ -50,11 +50,11 @@ class PowerPraiseImport(SongImport): root = objectify.parse(xml_file).getroot() except etree.XMLSyntaxError: log.exception('XML syntax error in file {name}'.format(name=file_path)) - self.log_error(file_path, SongStrings.XMLSyntaxError) + self.log_error(file_path, SongStrings().XMLSyntaxError) continue except UnicodeDecodeError: log.exception('Unreadable characters in {name}'.format(name=file_path)) - self.log_error(file_path, SongStrings.XMLSyntaxError) + self.log_error(file_path, SongStrings().XMLSyntaxError) continue self.process_song(root, file_path) diff --git a/openlp/plugins/songs/lib/importers/propresenter.py b/openlp/plugins/songs/lib/importers/propresenter.py index afe7a9da7..d5da2dcf9 100644 --- a/openlp/plugins/songs/lib/importers/propresenter.py +++ b/openlp/plugins/songs/lib/importers/propresenter.py @@ -54,11 +54,11 @@ class ProPresenterImport(SongImport): root = objectify.parse(xml_file).getroot() except etree.XMLSyntaxError: log.exception('XML syntax error in file {name}'.format(name=file_path)) - self.log_error(file_path, SongStrings.XMLSyntaxError) + self.log_error(file_path, SongStrings().XMLSyntaxError) continue except UnicodeDecodeError: log.exception('Unreadable characters in {name}'.format(name=file_path)) - self.log_error(file_path, SongStrings.XMLSyntaxError) + self.log_error(file_path, SongStrings().XMLSyntaxError) continue try: self.process_song(root, file_path) diff --git a/openlp/plugins/songs/lib/importers/songimport.py b/openlp/plugins/songs/lib/importers/songimport.py index 0535f6a92..5fb57c54d 100644 --- a/openlp/plugins/songs/lib/importers/songimport.py +++ b/openlp/plugins/songs/lib/importers/songimport.py @@ -104,7 +104,7 @@ class SongImport(QtCore.QObject): self.verse_counts = {} self.copyright_string = translate('SongsPlugin.SongImport', 'copyright') - def log_error(self, file_path, reason=SongStrings.SongIncomplete): + def log_error(self, file_path, reason=SongStrings().SongIncomplete): """ This should be called, when a song could not be imported. @@ -151,11 +151,11 @@ class SongImport(QtCore.QObject): :param text: Some text """ lines = text.split('\n') - if text.lower().find(self.copyright_string) >= 0 or text.find(str(SongStrings.CopyrightSymbol)) >= 0: + if text.lower().find(self.copyright_string) >= 0 or text.find(str(SongStrings().CopyrightSymbol)) >= 0: copyright_found = False for line in lines: if (copyright_found or line.lower().find(self.copyright_string) >= 0 or - line.find(str(SongStrings.CopyrightSymbol)) >= 0): + line.find(str(SongStrings().CopyrightSymbol)) >= 0): copyright_found = True self.add_copyright(line) else: diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index eaaa18bea..5bb3a8887 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -124,7 +124,7 @@ class SongMediaItem(MediaManagerItem): def retranslate_ui(self): self.search_text_label.setText('{text}:'.format(text=UiStrings().Search)) self.search_text_button.setText(UiStrings().Search) - self.maintenance_action.setText(SongStrings.SongMaintenance) + self.maintenance_action.setText(SongStrings().SongMaintenance) self.maintenance_action.setToolTip(translate('SongsPlugin.MediaItem', 'Maintain the lists of authors, topics and books.')) @@ -145,11 +145,11 @@ class SongMediaItem(MediaManagerItem): (SongSearch.Lyrics, UiIcons().search_lyrics, translate('SongsPlugin.MediaItem', 'Lyrics'), translate('SongsPlugin.MediaItem', 'Search Lyrics...')), - (SongSearch.Authors, UiIcons().user, SongStrings.Authors, + (SongSearch.Authors, UiIcons().user, SongStrings().Authors, translate('SongsPlugin.MediaItem', 'Search Authors...')), - (SongSearch.Topics, UiIcons().light_bulb, SongStrings.Topics, + (SongSearch.Topics, UiIcons().light_bulb, SongStrings().Topics, translate('SongsPlugin.MediaItem', 'Search Topics...')), - (SongSearch.Books, UiIcons().address, SongStrings.SongBooks, + (SongSearch.Books, UiIcons().address, SongStrings().SongBooks, translate('SongsPlugin.MediaItem', 'Search Songbooks...')), (SongSearch.Themes, UiIcons().theme, UiStrings().Themes, UiStrings().SearchThemes), (SongSearch.Copyright, UiIcons().copyright, @@ -673,7 +673,7 @@ class SongMediaItem(MediaManagerItem): authors=create_separated_list(authors.translation)) ) if song.copyright: - item.raw_footer.append("{symbol} {song}".format(symbol=SongStrings.CopyrightSymbol, + item.raw_footer.append("{symbol} {song}".format(symbol=SongStrings().CopyrightSymbol, song=song.copyright)) if song.songbook_entries: item.raw_footer.append(", ".join(songbooks)) diff --git a/openlp/plugins/songs/lib/ui.py b/openlp/plugins/songs/lib/ui.py index 12defed4e..370812682 100644 --- a/openlp/plugins/songs/lib/ui.py +++ b/openlp/plugins/songs/lib/ui.py @@ -32,18 +32,19 @@ class SongStrings(object): """ Provide standard strings for use throughout the songs plugin. """ - # These strings should need a good reason to be retranslated elsewhere. - Author = translate('OpenLP.Ui', 'Author', 'Singular') - Authors = translate('OpenLP.Ui', 'Authors', 'Plural') - AuthorUnknown = translate('OpenLP.Ui', 'Author Unknown') # Used to populate the database. - CopyrightSymbol = '\xa9' - SongBook = translate('OpenLP.Ui', 'Songbook', 'Singular') - SongBooks = translate('OpenLP.Ui', 'Songbooks', 'Plural') - SongIncomplete = translate('OpenLP.Ui', 'Title and/or verses not found') - SongMaintenance = translate('OpenLP.Ui', 'Song Maintenance') - Topic = translate('OpenLP.Ui', 'Topic', 'Singular') - Topics = translate('OpenLP.Ui', 'Topics', 'Plural') - XMLSyntaxError = translate('OpenLP.Ui', 'XML syntax error') + def __init__(self): + # These strings should need a good reason to be retranslated elsewhere. + self.Author = translate('OpenLP.Ui', 'Author', 'Singular') + self.Authors = translate('OpenLP.Ui', 'Authors', 'Plural') + self.AuthorUnknown = translate('OpenLP.Ui', 'Author Unknown') # Used to populate the database. + self.CopyrightSymbol = '\xa9' + self.SongBook = translate('OpenLP.Ui', 'Songbook', 'Singular') + self.SongBooks = translate('OpenLP.Ui', 'Songbooks', 'Plural') + self.SongIncomplete = translate('OpenLP.Ui', 'Title and/or verses not found') + self.SongMaintenance = translate('OpenLP.Ui', 'Song Maintenance') + self.Topic = translate('OpenLP.Ui', 'Topic', 'Singular') + self.Topics = translate('OpenLP.Ui', 'Topics', 'Plural') + self.XMLSyntaxError = translate('OpenLP.Ui', 'XML syntax error') def show_key_warning(parent): diff --git a/resources/forms/songmaintenance.ui b/resources/forms/songmaintenance.ui index 878fd7849..d40825be6 100644 --- a/resources/forms/songmaintenance.ui +++ b/resources/forms/songmaintenance.ui @@ -107,8 +107,7 @@ - -Authors + Authors AlignHCenter|AlignVCenter|AlignCenter @@ -120,8 +119,7 @@ Authors - -Topics + Topics AlignHCenter|AlignVCenter|AlignCenter @@ -133,8 +131,7 @@ Topics - -Books/Hymnals + Books/Hymnals AlignHCenter|AlignVCenter|AlignCenter diff --git a/tests/openlp_plugins/songs/test_openlyricsimport.py b/tests/openlp_plugins/songs/test_openlyricsimport.py index 72e388b6b..795eec04c 100644 --- a/tests/openlp_plugins/songs/test_openlyricsimport.py +++ b/tests/openlp_plugins/songs/test_openlyricsimport.py @@ -111,14 +111,14 @@ def test_can_parse_file_having_a_processing_instruction(mocked_logger: MagicMock # otherwise we don't care about it now (but should in other tests...) assert ex is not etree.XMLSyntaxError - # THEN: the importer's log_error method was never called with SongStrings.XMLSyntaxError as its second + # THEN: the importer's log_error method was never called with SongStrings().XMLSyntaxError as its second # positional argument if importer.log_error.called: for call_args in importer.log_error.call_args_list: args = call_args[0] # there are at least two positional arguments if len(args) > 1: - assert args[1] is not SongStrings.XMLSyntaxError + assert args[1] is not SongStrings().XMLSyntaxError # THEN: the logger's 'exception' method was never called with a first positional argument # which is a string and starts with 'XML syntax error in file'