Strings and magic numbers

This commit is contained in:
Jon Tibble 2011-02-13 01:09:04 +00:00
parent ad03f8588e
commit 323ab52848
16 changed files with 62 additions and 66 deletions

View File

@ -417,8 +417,7 @@ class MediaManagerItem(QtGui.QWidget):
item to the preview slide controller.
"""
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 to preview.'))
else:
@ -434,8 +433,7 @@ class MediaManagerItem(QtGui.QWidget):
item to the live slide controller.
"""
if not self.listView.selectedIndexes():
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 to send live.'))
else:

View File

@ -86,6 +86,7 @@ class UiStrings(object):
ResetLiveBG = translate('OpenLP.Ui', 'Reset Live Background')
SaveType = unicode(translate('OpenLP.Ui', 'Save %s'))
Search = translate('OpenLP.Ui', 'Search')
SelectDelete = translate('OpenLP.Ui', 'You must select an item to delete.')
SendSelectLive = unicode(translate('OpenLP.Ui',
'Send the selected %s live.'))
Service = translate('OpenLP.Ui', 'Service')

View File

@ -167,7 +167,7 @@ class DisplayTagTab(SettingsTab):
self.deletePushButton.setText(UiStrings.Delete)
self.defaultPushButton.setText(
translate('OpenLP.DisplayTagTab', 'Default'))
self.newPushButton.setText(translate('OpenLP.DisplayTagTab', 'New'))
self.newPushButton.setText(UiStrings.New)
self.tagTableWidget.horizontalHeaderItem(0)\
.setText(translate('OpenLP.DisplayTagTab', 'Description'))
self.tagTableWidget.horizontalHeaderItem(1)\

View File

@ -301,7 +301,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
'Edit Theme - %s')) % self.theme.theme_name)
self.next()
else:
self.setWindowTitle(translate('OpenLP.ThemeWizard', 'New Theme'))
self.setWindowTitle(UiStrings.NewType % UiStrings.Theme)
return QtGui.QWizard.exec_(self)
def initializePage(self, id):

View File

@ -63,10 +63,17 @@ class WizardStrings(object):
FinishedType = unicode(translate('OpenLP.Ui', 'Finished %s.'))
FormatLabel = translate('OpenLP.Ui', 'Format:')
Importing = translate('OpenLP.Ui', 'Importing')
ImportingType = unicode(translate('OpenLP.Ui', 'Importing %s...'))
ImportSelect = translate('OpenLP.Ui', 'Select Import Source')
ImportSelectLong = unicode(translate('OpenLP.Ui',
'Select the import format and the location to import from.'))
NoSqlite = translate('OpenLP.Ui', 'The openlp.org 1.x importer has been '
'disabled due to a missing Python module. If you want to use this '
'importer, you will need to install the "python-sqlite" '
'module.')
OpenTypeFile = unicode(translate('OpenLP.Ui', 'Open %s File'))
Ready = translate('OpenLP.Ui', 'Ready.')
StartingImport = translate('OpenLP.Ui', 'Starting import...')
Welcome = u'<span style="font-size:14pt; font-weight:600;">%s</span>' % \
translate('OpenLP.Ui', 'Welcome to the %s %s Wizard',
'Variable 1 is the type e.g. Bible and variable 2 is import/export')

View File

@ -26,7 +26,8 @@
from PyQt4 import QtGui, QtCore
from openlp.core.lib import translate
from openlp.core.lib import translate, StringContent
from openlp.core.lib.ui import UiStrings
from openlp.plugins.alerts.lib.db import AlertItem
from alertdialog import Ui_AlertDialog
@ -95,8 +96,8 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
def onNewClick(self):
if len(self.alertTextEdit.text()) == 0:
QtGui.QMessageBox.information(self,
translate('AlertsPlugin.AlertForm', 'New Alert'),
QtGui.QMessageBox.information(self, UiStrings.NewType %
self.plugin.getString(StringContent.Name)[u'singular']
translate('AlertsPlugin.AlertForm', 'You haven\'t specified '
'any text for your alert. Please type in some text before '
'clicking New.'))

View File

@ -370,13 +370,12 @@ class BibleImportForm(OpenLPWizard):
self.selectPage.setTitle(WizardStrings.ImportSelect)
self.selectPage.setSubTitle(WizardStrings.ImportSelectLong)
self.formatLabel.setText(WizardStrings.FormatLabel)
self.formatComboBox.setItemText(0, WizardStrings.OSIS)
self.formatComboBox.setItemText(1, WizardStrings.CSV)
self.formatComboBox.setItemText(2, WizardStrings.OS)
self.formatComboBox.setItemText(3,
self.formatComboBox.setItemText(BibleFormat.OSIS, WizardStrings.OSIS)
self.formatComboBox.setItemText(BibleFormat.CSV, WizardStrings.CSV)
self.formatComboBox.setItemText(BibleFormat.OpenSong, WizardStrings.OS)
self.formatComboBox.setItemText(BibleFormat.WebDownload,
translate('BiblesPlugin.ImportWizardForm', 'Web Download'))
self.formatComboBox.setItemText(4,
translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x'))
self.formatComboBox.setItemText(BibleFormat.OpenLP1, UiStrings.OLPV1)
self.openlp1FileLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Bible file:'))
self.osisFileLabel.setText(
@ -427,14 +426,9 @@ class BibleImportForm(OpenLPWizard):
self.progressPage.setSubTitle(
translate('BiblesPlugin.ImportWizardForm',
'Please wait while your Bible is imported.'))
self.progressLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Ready.'))
self.progressLabel.setText(WizardStrings.Ready)
self.progressBar.setFormat(u'%p%')
self.openlp1DisabledLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'The openlp.org 1.x '
'importer has been disabled due to a missing Python module. If '
'you want to use this importer, you will need to install the '
'"python-sqlite" module.'))
self.openlp1DisabledLabel.setText(WizardStrings.NoSqlite)
# Align all QFormLayouts towards each other.
labelWidth = max(self.formatLabel.minimumSizeHint().width(),
self.osisFileLabel.minimumSizeHint().width(),
@ -580,7 +574,7 @@ class BibleImportForm(OpenLPWizard):
"""
Show the file open dialog for the openlp.org 1.x file.
"""
self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OLPV1,
self.getFileName(WizardStrings.OpenTypeFile % UiStrings.OLPV1,
self.openlp1FileEdit, u'%s (*.bible)' %
translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x bible'))
@ -699,8 +693,7 @@ class BibleImportForm(OpenLPWizard):
'BiblesPlugin.ImportWizardForm',
'Starting Registering bible...'))
else:
self.progressLabel.setText(translate(
'BiblesPlugin.ImportWizardForm', 'Starting import...'))
self.progressLabel.setText(translate(WizardStrings.StartingImport)
Receiver.send_message(u'openlp_process_events')
def performWizard(self):

View File

@ -30,6 +30,7 @@ import sqlite
from PyQt4 import QtCore
from openlp.core.lib import Receiver, translate
from openlp.core.ui.wizard import WizardStrings
from openlp.plugins.bibles.lib.db import BibleDB
log = logging.getLogger(__name__)
@ -73,8 +74,7 @@ class OpenLP1Bible(BibleDB):
abbreviation = unicode(book[3], u'cp1252')
self.create_book(name, abbreviation, testament_id)
# Update the progess bar.
self.wizard.incrementProgressBar(unicode(translate(
'BiblesPlugin.OpenLP1Import', 'Importing %s...')) % name)
self.wizard.incrementProgressBar(WizardStrings.ImportingType % name)
# Import the verses for this book.
cursor.execute(u'SELECT chapter, verse, text || \'\' AS text FROM '
'verse WHERE book_id=%s' % book_id)

View File

@ -30,7 +30,7 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
SettingsManager, translate, check_item_selected, Receiver
SettingsManager, translate, check_item_selected, Receiver, StringContent
from openlp.core.lib.ui import UiStrings, critical_error_message_box
log = logging.getLogger(__name__)
@ -121,7 +121,7 @@ class MediaMediaItem(MediaManagerItem):
filename = unicode(item.data(QtCore.Qt.UserRole).toString())
if os.path.exists(filename):
service_item.title = unicode(
translate('MediaPlugin.MediaItem', 'Media'))
self.plugin.getString(StringContent.Name)[u'singular'])
service_item.add_capability(ItemCapabilities.RequiresMedia)
# force a nonexistent theme
service_item.theme = -1

View File

@ -31,7 +31,8 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, build_icon, SettingsManager, \
translate, check_item_selected, Receiver, ItemCapabilities
from openlp.core.lib.ui import critical_error_message_box, media_item_combo_box
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
media_item_combo_box
from openlp.plugins.presentations.lib import MessageListener
log = logging.getLogger(__name__)
@ -202,9 +203,7 @@ class PresentationMediaItem(MediaManagerItem):
"""
Remove a presentation item from the list
"""
if check_item_selected(self.listView,
translate('PresentationPlugin.MediaItem',
'You must select an item to delete.')):
if check_item_selected(self.listView, UiStrings.SelectDelete):
items = self.listView.selectedIndexes()
row_list = [item.row() for item in items]
row_list.sort(reverse=True)

View File

@ -191,8 +191,7 @@ class SongExportForm(OpenLPWizard):
self.progressPage.setSubTitle(
translate('SongsPlugin.ExportWizardForm',
'Please wait while your songs are exported.'))
self.progressLabel.setText(
translate('SongsPlugin.ExportWizardForm', 'Ready.'))
self.progressLabel.setText(WizardStrings.Ready)
self.progressBar.setFormat(
translate('SongsPlugin.ExportWizardForm', '%p%'))

View File

@ -206,29 +206,31 @@ class SongImportForm(OpenLPWizard):
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, UiStrings.OLPV1)
self.formatComboBox.setItemText(2, WizardStrings.OL)
self.formatComboBox.setItemText(3, WizardStrings.OS)
self.formatComboBox.setItemText(4, WizardStrings.WoW)
self.formatComboBox.setItemText(5, WizardStrings.CCLI)
self.formatComboBox.setItemText(6, WizardStrings.SoF)
self.formatComboBox.setItemText(7, WizardStrings.GDP)
self.formatComboBox.setItemText(8, WizardStrings.ES)
self.formatComboBox.setItemText(9, WizardStrings.EW)
self.formatComboBox.setItemText(10, WizardStrings.SB)
# self.formatComboBox.setItemText(11, WizardStrings.CSV)
self.formatComboBox.setItemText(SongFormat.OpenLP2, UiStrings.OLPV2)
self.formatComboBox.setItemText(SongFormat.OpenLP1, UiStrings.OLPV1)
self.formatComboBox.setItemText(
SongFormat.OpenLyrics, WizardStrings.OL)
self.formatComboBox.setItemText(SongFormat.OpenSong, WizardStrings.OS)
self.formatComboBox.setItemText(
SongFormat.WordsOfWorship, WizardStrings.WoW)
self.formatComboBox.setItemText(SongFormat.CCLI, WizardStrings.CCLI)
self.formatComboBox.setItemText(
SongFormat.SongsOfFellowship, WizardStrings.SoF)
self.formatComboBox.setItemText(SongFormat.Generic, WizardStrings.GDP)
self.formatComboBox.setItemText(
SongFormat.EasiSlides, WizardStrings.ES)
self.formatComboBox.setItemText(
SongFormat.EasyWorship, WizardStrings.EW)
self.formatComboBox.setItemText(
SongFormat.SongBeamer, WizardStrings.SB)
# self.formatComboBox.setItemText(SongFormat.CSV, WizardStrings.CSV)
self.openLP2FilenameLabel.setText(
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
self.openLP2BrowseButton.setText(UiStrings.Browse)
self.openLP1FilenameLabel.setText(
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
self.openLP1BrowseButton.setText(UiStrings.Browse)
self.openLP1DisabledLabel.setText(
translate('SongsPlugin.ImportWizardForm', 'The openlp.org 1.x '
'importer has been disabled due to a missing Python module. If '
'you want to use this importer, you will need to install the '
'"python-sqlite" module.'))
self.openLP1DisabledLabel.setText(WizardStrings.NoSqlite)
self.openLyricsAddButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.openLyricsRemoveButton.setText(
@ -283,8 +285,7 @@ class SongImportForm(OpenLPWizard):
self.progressPage.setSubTitle(
translate('SongsPlugin.ImportWizardForm',
'Please wait while your songs are imported.'))
self.progressLabel.setText(
translate('SongsPlugin.ImportWizardForm', 'Ready.'))
self.progressLabel.setText(WizardStrings.Ready)
self.progressBar.setFormat(
translate('SongsPlugin.ImportWizardForm', '%p%'))
# Align all QFormLayouts towards each other.
@ -573,8 +574,7 @@ class SongImportForm(OpenLPWizard):
Perform pre import tasks
"""
OpenLPWizard.preWizard(self)
self.progressLabel.setText(
translate('SongsPlugin.ImportWizardForm', 'Starting import...'))
self.progressLabel.setText(WizardStrings.StartingImport)
Receiver.send_message(u'openlp_process_events')
def performWizard(self):

View File

@ -67,10 +67,10 @@ class SongFormat(object):
CCLI = 5
SongsOfFellowship = 6
Generic = 7
#CSV = 8
EasiSlides = 8
EasyWorship = 9
SongBeamer = 10
#CSV = 11
@staticmethod
def get_class(format):

View File

@ -318,9 +318,7 @@ class SongMediaItem(MediaManagerItem):
"""
Remove a song from the list and database
"""
if check_item_selected(self.listView,
translate('SongsPlugin.MediaItem',
'You must select an item to delete.')):
if check_item_selected(self.listView, UiStrings.SelectDelete):
items = self.listView.selectedIndexes()
if QtGui.QMessageBox.question(self,
translate('SongsPlugin.MediaItem', 'Delete Song(s)?'),

View File

@ -34,6 +34,7 @@ import os
from lxml import etree
from openlp.core.lib import translate
from openlp.core.ui.wizard import WizardStrings
from openlp.plugins.songs.lib.songimport import SongImport
from openlp.plugins.songs.lib import OpenLyrics
@ -65,9 +66,8 @@ class OpenLyricsImport(SongImport):
for file_path in self.import_source:
if self.stop_import_flag:
return False
self.import_wizard.incrementProgressBar(unicode(translate(
'SongsPlugin.OpenLyricsImport', 'Importing %s...')) %
os.path.basename(file_path))
self.import_wizard.incrementProgressBar(
WizardStrings.ImportingType % os.path.basename(file_path))
try:
parsed_file = etree.parse(file_path, parser)
xml = unicode(etree.tostring(parsed_file))

View File

@ -34,6 +34,7 @@ import os
import re
from openlp.core.lib import translate
from openlp.core.ui.wizard import WizardStrings
from openlp.plugins.songs.lib.songimport import SongImport
log = logging.getLogger(__name__)
@ -134,9 +135,8 @@ class SongBeamerImport(SongImport):
self.add_verse(self.current_verse, self.current_verse_type)
if self.check_complete():
self.finish()
self.import_wizard.incrementProgressBar(unicode(translate(
'SongsPlugin.SongBeamerImport', 'Importing %s...')) %
file_name)
self.import_wizard.incrementProgressBar(
WizardStrings.ImportingType % file_name)
return True
def replace_html_tags(self):