From 8d18a51f09eda9d48a7c58c214642bb11faee6df Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 12 Feb 2011 02:43:13 +0000 Subject: [PATCH] WizardStrings --- openlp/core/lib/ui.py | 1 + openlp/core/ui/wizard.py | 23 +++++++++++-- .../plugins/bibles/forms/bibleimportform.py | 34 ++++++++----------- openlp/plugins/songs/forms/songexportform.py | 10 +++--- openlp/plugins/songs/forms/songimportform.py | 32 +++++++---------- 5 files changed, 53 insertions(+), 47 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 1c4137371..99b266e6e 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -55,6 +55,7 @@ class UiStrings(object): EditType = unicode(translate('OpenLP.Ui', 'Edit %s')) EmptyField = translate('OpenLP.Ui', 'Empty Field') Error = translate('OpenLP.Ui', 'Error') + Export = translate('OpenLP.Ui', 'Export') ExportType = unicode(translate('OpenLP.Ui', 'Export %s')) Import = translate('OpenLP.Ui', 'Import') ImportType = unicode(translate('OpenLP.Ui', 'Import %s')) diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index d3410ded9..fff1e2552 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -31,11 +31,30 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, Receiver, SettingsManager +from openlp.core.lib import build_icon, Receiver, SettingsManager, translate from openlp.core.lib.ui import UiStrings, add_welcome_page log = logging.getLogger(__name__) +class WizardStrings(object): + """ + Provide standard strings for wizards to use. + """ + # These strings should need a good reason to be retranslated elsewhere. + Description = unicode(translate('OpenLP.Ui', 'This wizard will help you ' + 'to %s %s from a variety of formats. Click the next button ' + 'below to start the process by selecting a format to %s from.', + 'Variable 1 & 3 are import/export. Variable 2 is a type like Bibles')) + FinishedType = unicode(translate('OpenLP.Ui', 'Finished %s.')) + FormatLabel = translate('OpenLP.Ui', 'Format:') + ImportSelect = translate('OpenLP.Ui', 'Select Import Source') + ImportSelectLong = unicode(translate('OpenLP.Ui', + 'Select the import format and the location to import from.')) + Welcome = u'%s' % \ + translate('OpenLP.Ui', 'Welcome to the %s %s Wizard', + 'Variable 1 is the type e.g. Bible and variable 2 is import/export') + + class OpenLPWizard(QtGui.QWizard): """ Generic OpenLP wizard to provide generic functionality and a unified look @@ -43,6 +62,7 @@ class OpenLPWizard(QtGui.QWizard): """ def __init__(self, parent, plugin, name, image): QtGui.QWizard.__init__(self, parent) + self.plugin = plugin self.setObjectName(name) self.openIcon = build_icon(u':/general/general_open.png') self.deleteIcon = build_icon(u':/general/general_delete.png') @@ -50,7 +70,6 @@ class OpenLPWizard(QtGui.QWizard): self.cancelButton = self.button(QtGui.QWizard.CancelButton) self.setupUi(image) self.registerFields() - self.plugin = plugin self.customInit() self.customSignals() QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 0e21b7496..d97299a42 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -33,10 +33,10 @@ import os.path from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, translate +from openlp.core.lib import Receiver, StringContent, translate from openlp.core.lib.db import delete_database from openlp.core.lib.ui import UiStrings, critical_error_message_box -from openlp.core.ui.wizard import OpenLPWizard +from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.core.utils import AppLocation, string_is_unicode from openlp.plugins.bibles.lib.manager import BibleFormat @@ -363,22 +363,16 @@ class BibleImportForm(OpenLPWizard): """ self.setWindowTitle( translate('BiblesPlugin.ImportWizardForm', 'Bible Import Wizard')) - self.titleLabel.setText( - u'%s' % \ - translate('BiblesPlugin.ImportWizardForm', - 'Welcome to the Bible Import Wizard')) - self.informationLabel.setText( - translate('BiblesPlugin.ImportWizardForm', - 'This wizard will help you to import Bibles from a ' - 'variety of formats. Click the next button below to start the ' - 'process by selecting a format to import from.')) - self.selectPage.setTitle(translate('BiblesPlugin.ImportWizardForm', - 'Select Import Source')) - self.selectPage.setSubTitle( - translate('BiblesPlugin.ImportWizardForm', - 'Select the import format, and where to import from.')) - self.formatLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Format:')) + self.titleLabel.setText(WizardStrings.Welcome % ( + self.plugin.getString(StringContent.Name)[u'singular'], + UiStrings.Import)) + self.informationLabel.setText(WizardStrings.Description % ( + UiStrings.Import.toLower(), + self.plugin.getString(StringContent.Name)[u'plural'], + UiStrings.Import.toLower())) + self.selectPage.setTitle(WizardStrings.ImportSelect) + self.selectPage.setSubTitle(WizardStrings.ImportSelectLong) + self.formatLabel.setText(WizardStrings.FormatLabel) self.formatComboBox.setItemText(0, translate('BiblesPlugin.ImportWizardForm', 'OSIS')) self.formatComboBox.setItemText(1, @@ -796,8 +790,8 @@ class BibleImportForm(OpenLPWizard): 'bible. Please note, that verses will be downloaded on\n' 'demand and thus an internet connection is required.')) else: - self.progressLabel.setText(translate( - 'BiblesPlugin.ImportWizardForm', 'Finished import.')) + self.progressLabel.setText( + WizardStrings.FinishedType % UiStrings.Import.toLower()) else: self.progressLabel.setText(translate( 'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.')) diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index 849a1ad1e..9e528a969 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -32,8 +32,8 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, Receiver, SettingsManager, translate -from openlp.core.lib.ui import critical_error_message_box -from openlp.core.ui.wizard import OpenLPWizard +from openlp.core.lib.ui import UiStrings, critical_error_message_box +from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.plugins.songs.lib.db import Song from openlp.plugins.songs.lib.openlyricsexport import OpenLyricsExport @@ -213,9 +213,7 @@ class SongExportForm(OpenLPWizard): self.availableListWidget) if item.checkState() ] if not items: - critical_error_message_box( - translate('SongsPlugin.ExportWizardForm', - 'No Song Selected'), + critical_error_message_box(UiStrings.NISp, translate('SongsPlugin.ExportWizardForm', 'You need to add at least one Song to export.')) return False @@ -289,7 +287,7 @@ class SongExportForm(OpenLPWizard): self, songs, unicode(self.directoryLineEdit.text())) if exporter.do_export(): self.progressLabel.setText( - translate('SongsPlugin.SongExportForm', 'Finished export.')) + WizardStrings.FinishedType % UiStrings.Export.toLower()) else: self.progressLabel.setText( translate('SongsPlugin.SongExportForm', diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index cb9d67b6a..b8dd2975a 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -31,9 +31,9 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, SettingsManager, translate +from openlp.core.lib import Receiver, SettingsManager, StringContent, translate from openlp.core.lib.ui import UiStrings, critical_error_message_box -from openlp.core.ui.wizard import OpenLPWizard +from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.plugins.songs.lib.importer import SongFormat log = logging.getLogger(__name__) @@ -199,22 +199,16 @@ class SongImportForm(OpenLPWizard): """ self.setWindowTitle( translate('SongsPlugin.ImportWizardForm', 'Song Import Wizard')) - self.titleLabel.setText( - u'%s' % \ - translate('SongsPlugin.ImportWizardForm', - 'Welcome to the Song Import Wizard')) - self.informationLabel.setText( - translate('SongsPlugin.ImportWizardForm', - 'This wizard will help you to import songs from a variety of ' - 'formats. Click the next button below to start the process by ' - 'selecting a format to import from.')) - self.sourcePage.setTitle( - translate('SongsPlugin.ImportWizardForm', 'Select Import Source')) - self.sourcePage.setSubTitle( - translate('SongsPlugin.ImportWizardForm', - 'Select the import format, and where to import from.')) - self.formatLabel.setText( - translate('SongsPlugin.ImportWizardForm', 'Format:')) + self.titleLabel.setText(WizardStrings.Welcome % ( + self.plugin.getString(StringContent.Name)[u'singular'], + UiStrings.Import)) + self.informationLabel.setText(WizardStrings.Description % ( + UiStrings.Import.toLower(), + self.plugin.getString(StringContent.Name)[u'plural'], + UiStrings.Import.toLower())) + self.sourcePage.setTitle(WizardStrings.ImportSelect) + self.sourcePage.setSubTitle(WizardStrings.ImportSelectLong) + self.formatLabel.setText(WizardStrings.FormatLabel) self.formatComboBox.setItemText(0, UiStrings.OLPV2) self.formatComboBox.setItemText(1, translate('SongsPlugin.ImportWizardForm', 'openlp.org 1.x')) @@ -719,7 +713,7 @@ class SongImportForm(OpenLPWizard): ) if importer.do_import(): self.progressLabel.setText( - translate('SongsPlugin.SongImportForm', 'Finished import.')) + WizardStrings.FinishedType % UiStrings.Import.toLower()) else: self.progressLabel.setText( translate('SongsPlugin.SongImportForm',