From 9366155924284ee2403279674a6325aa2352e224 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 11 Feb 2011 21:17:56 +0000 Subject: [PATCH] UiStrings and SongStrings --- openlp/core/lib/mediamanageritem.py | 10 ++-- openlp/core/lib/theme.py | 4 +- openlp/core/lib/ui.py | 15 +++--- openlp/core/ui/serviceitemeditdialog.py | 5 +- openlp/plugins/alerts/forms/alertdialog.py | 5 +- .../plugins/bibles/forms/bibleimportform.py | 33 ++++--------- openlp/plugins/custom/customplugin.py | 2 +- .../plugins/custom/forms/editcustomdialog.py | 6 ++- openlp/plugins/custom/forms/editcustomform.py | 7 +-- openlp/plugins/songs/forms/authorsdialog.py | 3 +- openlp/plugins/songs/forms/editsongdialog.py | 9 ++-- openlp/plugins/songs/forms/songbookdialog.py | 3 +- openlp/plugins/songs/forms/songimportform.py | 46 +++++-------------- .../songs/forms/songmaintenancedialog.py | 18 ++++---- openlp/plugins/songs/forms/topicsdialog.py | 3 +- openlp/plugins/songs/lib/mediaitem.py | 5 +- openlp/plugins/songs/lib/ui.py | 43 +++++++++++++++++ 17 files changed, 114 insertions(+), 103 deletions(-) create mode 100644 openlp/plugins/songs/lib/ui.py diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index f74ba63a9..52b4f560b 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -449,8 +449,7 @@ class MediaManagerItem(QtGui.QWidget): Add a selected item to the current service """ if not self.listView.selectedIndexes() and not self.remoteTriggered: - QtGui.QMessageBox.information(self, - translate('OpenLP.MediaManagerItem', 'No Items Selected'), + QtGui.QMessageBox.information(self, UiStrings.NISp, translate('OpenLP.MediaManagerItem', 'You must select one or more items.')) else: @@ -476,17 +475,14 @@ class MediaManagerItem(QtGui.QWidget): Add a selected item to an existing item in the current service. """ if not self.listView.selectedIndexes() and not self.remoteTriggered: - QtGui.QMessageBox.information(self, - translate('OpenLP.MediaManagerItem', 'No Items Selected'), + QtGui.QMessageBox.information(self, UiStrings.NISp, translate('OpenLP.MediaManagerItem', 'You must select one or more items')) else: log.debug(u'%s Add requested', self.plugin.name) serviceItem = self.parent.serviceManager.getServiceItem() if not serviceItem: - QtGui.QMessageBox.information(self, - translate('OpenLP.MediaManagerItem', - 'No Service Item Selected'), + QtGui.QMessageBox.information(self, UiStrings.NISs, translate('OpenLP.MediaManagerItem', 'You must select an existing service item to add to.')) elif self.plugin.name.lower() == serviceItem.name.lower(): diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 06340c2eb..67ce33ca4 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -178,9 +178,9 @@ class HorizontalType(object): """ Return a string representation of a horizontal type. """ - if horizontal_type == Horizontal.Right: + if horizontal_type == HorizontalType.Right: return u'right' - elif horizontal_type == Horizontal.Center: + elif horizontal_type == HorizontalType.Center: return u'center' else: return u'left' diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index a3b442801..0c5fe2bf9 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -46,7 +46,6 @@ class UiStrings(object): 'Add the selected %s to the service.')) Advanced = translate('OpenLP.Ui', 'Advanced') AllFiles = translate('OpenLP.Ui', 'All Files') - Authors = translate('OpenLP.Ui', 'Authors') CreateANew = unicode(translate('OpenLP.Ui', 'Create a new %s.')) Delete = translate('OpenLP.Ui', '&Delete') DeleteSelect = unicode(translate('OpenLP.Ui', 'Delete the selected %s.')) @@ -54,6 +53,7 @@ class UiStrings(object): Edit = translate('OpenLP.Ui', '&Edit') EditSelect = unicode(translate('OpenLP.Ui', 'Edit the selected %s.')) EditType = unicode(translate('OpenLP.Ui', 'Edit %s')) + EmptyField = translate('OpenLP.Ui', 'Empty Field') Error = translate('OpenLP.Ui', 'Error') ExportType = unicode(translate('OpenLP.Ui', 'Export %s')) Import = translate('OpenLP.Ui', 'Import') @@ -63,6 +63,10 @@ class UiStrings(object): LoadANew = unicode(translate('OpenLP.Ui', 'Load a new %s.')) New = translate('OpenLP.Ui', 'New') NewType = unicode(translate('OpenLP.Ui', 'New %s')) + NFSs = translate('OpenLP.Ui', 'No File Selected', 'Singular') + NFSp = translate('OpenLP.Ui', 'No Files Selected', 'Plural') + NISs = translate('OpenLP.Ui', 'No Item Selected', 'Singular') + NISp = translate('OpenLP.Ui', 'No Items Selected', 'Plural') OLPV2 = translate('OpenLP.Ui', 'OpenLP 2.0') OpenType = unicode(translate('OpenLP.Ui', 'Open %s')) Preview = translate('OpenLP.Ui', 'Preview') @@ -75,8 +79,8 @@ class UiStrings(object): SendSelectLive = unicode(translate('OpenLP.Ui', 'Send the selected %s live.')) Service = translate('OpenLP.Ui', 'Service') - Theme = translate('OpenLP.Ui', 'Theme') - Themes = translate('OpenLP.Ui', 'Themes') + Theme = translate('OpenLP.Ui', 'Theme', 'Singular') + Themes = translate('OpenLP.Ui', 'Themes', 'Plural') def add_welcome_page(parent, image): @@ -168,7 +172,7 @@ def media_item_combo_box(parent, name): combo.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) return combo -def create_delete_push_button(parent, icon=None): +def create_delete_push_button(parent, item_name, icon=None): """ Creates a standard push button with a delete label and optional icon. The button is connected to the parent's ``onDeleteButtonClicked()`` method to @@ -186,8 +190,7 @@ def create_delete_push_button(parent, icon=None): delete_icon = icon if icon else u':/general/general_delete.png' delete_button.setIcon(build_icon(delete_icon)) delete_button.setText(UiStrings.Delete) - delete_button.setToolTip( - translate('OpenLP.Ui', 'Delete the selected item.')) + delete_button.setToolTip(UiStrings.DeleteSelect % item_name) QtCore.QObject.connect(delete_button, QtCore.SIGNAL(u'clicked()'), parent.onDeleteButtonClicked) return delete_button diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index ef7e99a5f..0f9ddb4ac 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import create_accept_reject_button_box, \ +from openlp.core.lib.ui import UiStrings, create_accept_reject_button_box, \ create_delete_push_button, create_up_down_push_button_set class Ui_ServiceItemEditDialog(object): @@ -41,7 +41,8 @@ class Ui_ServiceItemEditDialog(object): self.dialogLayout.addWidget(self.listWidget, 0, 0) self.buttonLayout = QtGui.QVBoxLayout() self.buttonLayout.setObjectName(u'buttonLayout') - self.deleteButton = create_delete_push_button(serviceItemEditDialog) + self.deleteButton = create_delete_push_button( + serviceItemEditDialog, UiStrings.Service.toLower()) self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() self.upButton, self.downButton = create_up_down_push_button_set( diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index 93f7ead06..12f5c04be 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate +from openlp.core.lib import StringContent, build_icon, translate from openlp.core.lib.ui import create_delete_push_button class Ui_AlertDialog(object): @@ -66,7 +66,8 @@ class Ui_AlertDialog(object): self.saveButton.setIcon(build_icon(u':/general/general_save.png')) self.saveButton.setObjectName(u'saveButton') self.manageButtonLayout.addWidget(self.saveButton) - self.deleteButton = create_delete_push_button(alertDialog) + self.deleteButton = create_delete_push_button(alertDialog, + self.parent.getString(StringContent.Name)[u'singular'].toLower()) self.deleteButton.setEnabled(False) self.manageButtonLayout.addWidget(self.deleteButton) self.manageButtonLayout.addStretch() diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 463c838c9..0e21b7496 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -35,7 +35,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, translate from openlp.core.lib.db import delete_database -from openlp.core.lib.ui import critical_error_message_box +from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard from openlp.core.utils import AppLocation, string_is_unicode from openlp.plugins.bibles.lib.manager import BibleFormat @@ -468,9 +468,7 @@ class BibleImportForm(OpenLPWizard): elif self.currentPage() == self.selectPage: if self.field(u'source_format').toInt()[0] == BibleFormat.OSIS: if not self.field(u'osis_location').toString(): - critical_error_message_box( - translate('BiblesPlugin.ImportWizardForm', - 'Invalid Bible Location'), + critical_error_message_box(UiStrings.NFSs, translate('BiblesPlugin.ImportWizardForm', 'You need to specify a file to import your ' 'Bible from.')) @@ -478,8 +476,7 @@ class BibleImportForm(OpenLPWizard): return False elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV: if not self.field(u'csv_testamentsfile').toString(): - answer = critical_error_message_box(translate( - 'BiblesPlugin.ImportWizardForm', 'No Testaments File'), + answer = critical_error_message_box(UiStrings.NFSs, translate('BiblesPlugin.ImportWizardForm', 'You have not specified a testaments file. Do you ' 'want to proceed with the import?'), question=True) @@ -487,18 +484,14 @@ class BibleImportForm(OpenLPWizard): self.csvTestamentsEdit.setFocus() return False elif not self.field(u'csv_booksfile').toString(): - critical_error_message_box( - translate('BiblesPlugin.ImportWizardForm', - 'Invalid Books File'), + critical_error_message_box(UiStrings.NFSs, translate('BiblesPlugin.ImportWizardForm', 'You need to specify a file with books of ' 'the Bible to use in the import.')) self.csvBooksEdit.setFocus() return False elif not self.field(u'csv_versefile').toString(): - critical_error_message_box( - translate('BiblesPlugin.ImportWizardForm', - 'Invalid Verse File'), + critical_error_message_box(UiStrings.NFSs, translate('BiblesPlugin.ImportWizardForm', 'You need to specify a file of Bible ' 'verses to import.')) @@ -507,9 +500,7 @@ class BibleImportForm(OpenLPWizard): elif self.field(u'source_format').toInt()[0] == \ BibleFormat.OpenSong: if not self.field(u'opensong_file').toString(): - critical_error_message_box( - translate('BiblesPlugin.ImportWizardForm', - 'Invalid OpenSong Bible'), + critical_error_message_box(UiStrings.NFSs, translate('BiblesPlugin.ImportWizardForm', 'You need to specify an OpenSong Bible ' 'file to import.')) @@ -517,9 +508,7 @@ class BibleImportForm(OpenLPWizard): return False elif self.field(u'source_format').toInt()[0] == BibleFormat.OpenLP1: if not self.field(u'openlp1_location').toString(): - critical_error_message_box( - translate('BiblesPlugin.ImportWizardForm', - 'Invalid Bible Location'), + critical_error_message_box(UiStrings.NFSs, translate('BiblesPlugin.ImportWizardForm', 'You need to specify a file to import your ' 'Bible from.')) @@ -531,17 +520,13 @@ class BibleImportForm(OpenLPWizard): license_copyright = \ unicode(self.field(u'license_copyright').toString()) if not license_version: - critical_error_message_box( - translate('BiblesPlugin.ImportWizardForm', - 'Empty Version Name'), + critical_error_message_box(UiStrings.EmptyField, translate('BiblesPlugin.ImportWizardForm', 'You need to specify a version name for your Bible.')) self.versionNameEdit.setFocus() return False elif not license_copyright: - critical_error_message_box( - translate('BiblesPlugin.ImportWizardForm', - 'Empty Copyright'), + critical_error_message_box(UiStrings.EmptyField, translate('BiblesPlugin.ImportWizardForm', 'You need to set a copyright for your Bible. ' 'Bibles in the Public Domain need to be marked as such.')) diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 92546cd4f..13f5c5696 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -52,7 +52,7 @@ class CustomPlugin(Plugin): CustomMediaItem, CustomTab) self.weight = -5 self.manager = Manager(u'custom', init_schema) - self.edit_custom_form = EditCustomForm(self.manager) + self.edit_custom_form = EditCustomForm(self) self.icon_path = u':/plugins/plugin_custom.png' self.icon = build_icon(self.icon_path) diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 2e8a64a9d..e63c057d0 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -26,7 +26,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate +from openlp.core.lib import StringContent, build_icon, translate from openlp.core.lib.ui import UiStrings, create_accept_reject_button_box, \ create_delete_push_button, create_up_down_push_button_set @@ -66,7 +66,9 @@ class Ui_CustomEditDialog(object): self.editAllButton = QtGui.QPushButton(customEditDialog) self.editAllButton.setObjectName(u'editAllButton') self.buttonLayout.addWidget(self.editAllButton) - self.deleteButton = create_delete_push_button(customEditDialog) + self.deleteButton = create_delete_push_button(customEditDialog, + customEditDialog.parent.getString( + StringContent.Name)[u'singular'].toLower()) self.deleteButton.setEnabled(False) self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index b667cd529..a86b28489 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -42,14 +42,15 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): Class documentation goes here. """ log.info(u'Custom Editor loaded') - def __init__(self, manager, parent=None): + def __init__(self, parent): """ Constructor """ - QtGui.QDialog.__init__(self, parent) + QtGui.QDialog.__init__(self) + self.parent = parent + self.manager = self.parent.manager self.setupUi(self) # Create other objects and forms. - self.manager = manager self.editSlideForm = EditCustomSlideForm(self) # Connecting signals and slots QtCore.QObject.connect(self.previewButton, diff --git a/openlp/plugins/songs/forms/authorsdialog.py b/openlp/plugins/songs/forms/authorsdialog.py index 09c723364..6cfe83e67 100644 --- a/openlp/plugins/songs/forms/authorsdialog.py +++ b/openlp/plugins/songs/forms/authorsdialog.py @@ -28,6 +28,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate from openlp.core.lib.ui import create_accept_reject_button_box +from openlp.plugins.songs.lib.ui import SongStrings class Ui_AuthorsDialog(object): def setupUi(self, authorsDialog): @@ -64,7 +65,7 @@ class Ui_AuthorsDialog(object): def retranslateUi(self, authorsDialog): authorsDialog.setWindowTitle( - translate('SongsPlugin.AuthorsForm', 'Author Maintenance')) + SongStrings.TypeMaintenance % SongStrings.Author) self.displayLabel.setText( translate('SongsPlugin.AuthorsForm', 'Display name:')) self.firstNameLabel.setText( diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 234d92283..491f4fa74 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -28,6 +28,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate from openlp.core.lib.ui import UiStrings, create_accept_reject_button_box +from openlp.plugins.songs.lib.ui import SongStrings class Ui_EditSongDialog(object): def setupUi(self, editSongDialog): @@ -265,21 +266,19 @@ class Ui_EditSongDialog(object): self.songTabWidget.setTabText( self.songTabWidget.indexOf(self.lyricsTab), translate('SongsPlugin.EditSongForm', 'Title && Lyrics')) - self.authorsGroupBox.setTitle(UiStrings.Authors) + self.authorsGroupBox.setTitle(SongStrings.Authors) self.authorAddButton.setText( translate('SongsPlugin.EditSongForm', '&Add to Song')) self.authorRemoveButton.setText( translate('SongsPlugin.EditSongForm', '&Remove')) self.maintenanceButton.setText(translate('SongsPlugin.EditSongForm', '&Manage Authors, Topics, Song Books')) - self.topicsGroupBox.setTitle( - translate('SongsPlugin.EditSongForm', 'Topic')) + self.topicsGroupBox.setTitle(SongStrings.Topic) self.topicAddButton.setText( translate('SongsPlugin.EditSongForm', 'A&dd to Song')) self.topicRemoveButton.setText( translate('SongsPlugin.EditSongForm', 'R&emove')) - self.songBookGroupBox.setTitle( - translate('SongsPlugin.EditSongForm', 'Song Book')) + self.songBookGroupBox.setTitle(SongStrings.SongBook) self.songBookNameLabel.setText(translate('SongsPlugin.EditSongForm', 'Book:')) self.songBookNumberLabel.setText(translate('SongsPlugin.EditSongForm', diff --git a/openlp/plugins/songs/forms/songbookdialog.py b/openlp/plugins/songs/forms/songbookdialog.py index f6dd3930c..d185a9e1e 100644 --- a/openlp/plugins/songs/forms/songbookdialog.py +++ b/openlp/plugins/songs/forms/songbookdialog.py @@ -28,6 +28,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate from openlp.core.lib.ui import create_accept_reject_button_box +from openlp.plugins.songs.lib.ui import SongStrings class Ui_SongBookDialog(object): def setupUi(self, songBookDialog): @@ -58,7 +59,7 @@ class Ui_SongBookDialog(object): def retranslateUi(self, songBookDialog): songBookDialog.setWindowTitle( - translate('SongsPlugin.SongBookForm', 'Song Book Maintenance')) + SongStrings.TypeMaintenance % SongStrings.SongBook) self.nameLabel.setText(translate('SongsPlugin.SongBookForm', '&Name:')) self.publisherLabel.setText( translate('SongsPlugin.SongBookForm', '&Publisher:')) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index b84af8dde..cb9d67b6a 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -330,9 +330,7 @@ class SongImportForm(OpenLPWizard): source_format = self.formatComboBox.currentIndex() if source_format == SongFormat.OpenLP2: if self.openLP2FilenameEdit.text().isEmpty(): - critical_error_message_box( - translate('SongsPlugin.ImportWizardForm', - 'No OpenLP 2.0 Song Database Selected'), + critical_error_message_box(UiStrings.NFSs, translate('SongsPlugin.ImportWizardForm', 'You need to select an OpenLP 2.0 song database ' 'file to import from.')) @@ -340,9 +338,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.OpenLP1: if self.openLP1FilenameEdit.text().isEmpty(): - critical_error_message_box( - translate('SongsPlugin.ImportWizardForm', - 'No openlp.org 1.x Song Database Selected'), + critical_error_message_box(UiStrings.NFSs, translate('SongsPlugin.ImportWizardForm', 'You need to select an openlp.org 1.x song ' 'database file to import from.')) @@ -350,9 +346,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.OpenLyrics: if self.openLyricsFileListWidget.count() == 0: - critical_error_message_box( - translate('SongsPlugin.ImportWizardForm', - 'No OpenLyrics Files Selected'), + critical_error_message_box(UiStrings.NFSp, translate('SongsPlugin.ImportWizardForm', 'You need to add at least one OpenLyrics ' 'song file to import from.')) @@ -360,9 +354,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.OpenSong: if self.openSongFileListWidget.count() == 0: - critical_error_message_box( - translate('SongsPlugin.ImportWizardForm', - 'No OpenSong Files Selected'), + critical_error_message_box(UiStrings.NFSp, translate('SongsPlugin.ImportWizardForm', 'You need to add at least one OpenSong ' 'song file to import from.')) @@ -370,9 +362,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.WordsOfWorship: if self.wordsOfWorshipFileListWidget.count() == 0: - critical_error_message_box( - translate('SongsPlugin.ImportWizardForm', - 'No Words of Worship Files Selected'), + critical_error_message_box(UiStrings.NFSp, translate('SongsPlugin.ImportWizardForm', 'You need to add at least one Words of Worship ' 'file to import from.')) @@ -380,9 +370,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.CCLI: if self.ccliFileListWidget.count() == 0: - critical_error_message_box( - translate('SongsPlugin.ImportWizardForm', - 'No CCLI Files Selected'), + critical_error_message_box(UiStrings.NFSp, translate('SongsPlugin.ImportWizardForm', 'You need to add at least one CCLI file ' 'to import from.')) @@ -390,9 +378,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.SongsOfFellowship: if self.songsOfFellowshipFileListWidget.count() == 0: - critical_error_message_box( - translate('SongsPlugin.ImportWizardForm', - 'No Songs of Fellowship File Selected'), + critical_error_message_box(UiStrings.NFSp, translate('SongsPlugin.ImportWizardForm', 'You need to add at least one Songs of Fellowship ' 'file to import from.')) @@ -400,9 +386,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.Generic: if self.genericFileListWidget.count() == 0: - critical_error_message_box( - translate('SongsPlugin.ImportWizardForm', - 'No Document/Presentation Selected'), + critical_error_message_box(UiStrings.NFSp, translate('SongsPlugin.ImportWizardForm', 'You need to add at least one document or ' 'presentation file to import from.')) @@ -410,9 +394,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.EasiSlides: if self.easiSlidesFilenameEdit.text().isEmpty(): - critical_error_message_box( - translate('SongsPlugin.ImportWizardForm', - 'No Easislides Songs file selected'), + critical_error_message_box(UiStrings.NFSp, translate('SongsPlugin.ImportWizardForm', 'You need to select an xml song file exported from ' 'EasiSlides, to import from.')) @@ -420,9 +402,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.EasyWorship: if self.ewFilenameEdit.text().isEmpty(): - critical_error_message_box( - translate('SongsPlugin.ImportWizardForm', - 'No EasyWorship Song Database Selected'), + critical_error_message_box(UiStrings.NFSs, translate('SongsPlugin.ImportWizardForm', 'You need to select an EasyWorship song database ' 'file to import from.')) @@ -430,9 +410,7 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.SongBeamer: if self.songBeamerFileListWidget.count() == 0: - critical_error_message_box( - translate('SongsPlugin.ImportWizardForm', - 'No SongBeamer File Selected'), + critical_error_message_box(UiStrings.NFSp, translate('SongsPlugin.ImportWizardForm', 'You need to add at least one SongBeamer ' 'file to import from.')) @@ -585,7 +563,7 @@ class SongImportForm(OpenLPWizard): 'Select Songs of Fellowship Files'), self.songsOfFellowshipFileListWidget, u'%s (*.rtf)' % translate('SongsPlugin.ImportWizardForm', - 'Songs Of Felloship Song Files') + 'Songs Of Fellowship Song Files') ) def onSongsOfFellowshipRemoveButtonClicked(self): diff --git a/openlp/plugins/songs/forms/songmaintenancedialog.py b/openlp/plugins/songs/forms/songmaintenancedialog.py index 0fa3335dc..10827868c 100644 --- a/openlp/plugins/songs/forms/songmaintenancedialog.py +++ b/openlp/plugins/songs/forms/songmaintenancedialog.py @@ -28,6 +28,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, translate from openlp.core.lib.ui import UiStrings +from openlp.plugins.songs.lib.ui import SongStrings class Ui_SongMaintenanceDialog(object): def setupUi(self, songMaintenanceDialog): @@ -145,13 +146,10 @@ class Ui_SongMaintenanceDialog(object): def retranslateUi(self, songMaintenanceDialog): songMaintenanceDialog.setWindowTitle( - translate('SongsPlugin.SongMaintenanceForm', 'Song Maintenance')) - authorsString = UiStrings.Authors - topicsString = translate('SongsPlugin.SongMaintenanceForm', 'Topics') - booksString = translate('SongsPlugin.SongMaintenanceForm', 'Song Books') - self.listItemAuthors.setText(authorsString) - self.listItemTopics.setText(topicsString) - self.listItemBooks.setText(booksString) + SongStrings.TypeMaintenance % SongStrings.Song) + self.listItemAuthors.setText(SongStrings.Authors) + self.listItemTopics.setText(SongStrings.Topics) + self.listItemBooks.setText(SongStrings.SongBooks) self.authorsAddButton.setText(UiStrings.Add) self.authorsEditButton.setText(UiStrings.Edit) self.authorsDeleteButton.setText(UiStrings.Delete) @@ -161,8 +159,8 @@ class Ui_SongMaintenanceDialog(object): self.booksAddButton.setText(UiStrings.Add) self.booksEditButton.setText(UiStrings.Edit) self.booksDeleteButton.setText(UiStrings.Delete) - typeListWidth = max(self.fontMetrics().width(authorsString), - self.fontMetrics().width(topicsString), - self.fontMetrics().width(booksString)) + typeListWidth = max(self.fontMetrics().width(SongStrings.Authors), + self.fontMetrics().width(SongStrings.Topics), + self.fontMetrics().width(SongStrings.SongBooks)) self.typeListWidget.setFixedWidth(typeListWidth + self.typeListWidget.iconSize().width() + 32) diff --git a/openlp/plugins/songs/forms/topicsdialog.py b/openlp/plugins/songs/forms/topicsdialog.py index 1e7bdb6a0..4e2349019 100644 --- a/openlp/plugins/songs/forms/topicsdialog.py +++ b/openlp/plugins/songs/forms/topicsdialog.py @@ -28,6 +28,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate from openlp.core.lib.ui import create_accept_reject_button_box +from openlp.plugins.songs.lib.ui import SongStrings class Ui_TopicsDialog(object): def setupUi(self, topicsDialog): @@ -52,6 +53,6 @@ class Ui_TopicsDialog(object): def retranslateUi(self, topicsDialog): topicsDialog.setWindowTitle( - translate('SongsPlugin.TopicsForm', 'Topic Maintenance')) + SongStrings.TypeMaintenance % SongStrings.Topic) self.nameLabel.setText( translate('SongsPlugin.TopicsForm', 'Topic name:')) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 283aa6c03..8d704d51d 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -38,6 +38,7 @@ from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \ SongImportForm, SongExportForm from openlp.plugins.songs.lib import OpenLyrics, SongXML from openlp.plugins.songs.lib.db import Author, Song +from openlp.plugins.songs.lib.ui import SongStrings from openlp.core.lib.searchedit import SearchEdit log = logging.getLogger(__name__) @@ -129,7 +130,7 @@ class SongMediaItem(MediaManagerItem): self.searchTextButton.setText( translate('SongsPlugin.MediaItem', 'Search')) self.maintenanceAction.setText( - translate('SongsPlugin.MediaItem', 'Song Maintenance')) + SongStrings.TypeMaintenance % SongString.Song) self.maintenanceAction.setToolTip(translate('SongsPlugin.MediaItem', 'Maintain the lists of authors, topics and books')) @@ -141,7 +142,7 @@ class SongMediaItem(MediaManagerItem): translate('SongsPlugin.MediaItem', 'Titles')), (3, u':/songs/song_search_lyrics.png', translate('SongsPlugin.MediaItem', 'Lyrics')), - (4, u':/songs/song_search_author.png', UiStrings.Authors), + (4, u':/songs/song_search_author.png', SongStrings.Authors), (5, u':/slides/slide_theme.png', UiStrings.Themes) ]) self.configUpdated() diff --git a/openlp/plugins/songs/lib/ui.py b/openlp/plugins/songs/lib/ui.py new file mode 100644 index 000000000..2a67fce55 --- /dev/null +++ b/openlp/plugins/songs/lib/ui.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2011 Raoul Snyman # +# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # +# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +The :mod:`openlp.plugins.songs.lib.ui` module provides standard UI components +for the songs plugin. +""" +from openlp.core.lib import translate + +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') + SongBook = translate('OpenLP.Ui', 'Song Book', 'Singular') + SongBooks = translate('OpenLP.Ui', 'Song Books', 'Plural') + Topic = translate('OpenLP.Ui', 'Topic', 'Singular') + Topics = translate('OpenLP.Ui', 'Topics', 'Plural') + TypeMaintenance = unicode(translate('OpenLP.Ui', '%s Maintenance'))