Fixed all translate() function in ImagePlugin

This commit is contained in:
Frode Woldsund 2010-06-06 15:26:42 +02:00
parent 0788937721
commit febb743acd
8 changed files with 92 additions and 54 deletions

View File

@ -67,10 +67,11 @@ class CustomPlugin(Plugin):
self.remove_toolbox_item() self.remove_toolbox_item()
def about(self): def about(self):
about_text = translate('CustomPlugin','<b>Custom Plugin</b><br>This plugin ' about_text = translate(u'CustomPlugin.CustomPlugin',
'allows slides to be displayed on the screen in the same way ' u'<b>Custom Plugin</b><br>This plugin '
'songs are. This plugin provides greater freedom over the ' u'allows slides to be displayed on the screen in the same way '
'songs plugin.<br>') u'songs are. This plugin provides greater freedom over the '
u'songs plugin.<br>')
return about_text return about_text
def can_delete_theme(self, theme): def can_delete_theme(self, theme):

View File

@ -153,23 +153,46 @@ class Ui_customEditDialog(object):
customEditDialog.setTabOrder(self.DownButton, self.ThemeComboBox) customEditDialog.setTabOrder(self.DownButton, self.ThemeComboBox)
def retranslateUi(self, customEditDialog): def retranslateUi(self, customEditDialog):
customEditDialog.setWindowTitle(translate('EditCustomForm', 'Edit Custom Slides')) customEditDialog.setWindowTitle(translate(u'CustomPlugin.EditCustomForm',
self.UpButton.setToolTip(translate('EditCustomForm', 'Move slide Up 1')) u'Edit Custom Slides'))
self.DownButton.setToolTip(translate('EditCustomForm', 'Move slide down 1')) self.UpButton.setToolTip(
self.TitleLabel.setText(translate('EditCustomForm', 'Title:')) translate(u'CustomPlugin.EditCustomForm'
self.AddButton.setText(translate('EditCustomForm', 'Add New')) u'CustomPlugin.EditCustomForm',
self.AddButton.setToolTip(translate('EditCustomForm', 'Add new slide at bottom')) u'Move slide Up 1'))
self.EditButton.setText(translate('EditCustomForm', 'Edit')) self.DownButton.setToolTip(
self.EditButton.setToolTip(translate('EditCustomForm', 'Edit selected slide')) translate(u'CustomPlugin.EditCustomForm', u'Move slide down 1'))
self.EditAllButton.setText(translate('EditCustomForm', 'Edit All')) self.TitleLabel.setText(
self.EditAllButton.setToolTip(translate('EditCustomForm', 'Edit all slides')) translate(u'CustomPlugin.EditCustomForm', u'Title:'))
self.SaveButton.setText(translate('EditCustomForm', 'Save')) self.AddButton.setText(
self.SaveButton.setToolTip(translate('EditCustomForm', 'Replace edited slide')) translate(u'CustomPlugin.EditCustomForm', u'Add New'))
self.DeleteButton.setText(translate('EditCustomForm', 'Delete')) self.AddButton.setToolTip(
self.DeleteButton.setToolTip(translate('EditCustomForm', 'Delete selected slide')) translate(u'CustomPlugin.EditCustomForm',
self.ClearButton.setText(translate('EditCustomForm', 'Clear')) u'Add new slide at bottom'))
self.ClearButton.setToolTip(translate('EditCustomForm', 'Clear edit area')) self.EditButton.setText(
self.SplitButton.setText(translate('EditCustomForm', 'Split Slide')) translate(u'CustomPlugin.EditCustomForm', u'Edit'))
self.SplitButton.setToolTip(translate('EditCustomForm', 'Add slide split')) self.EditButton.setToolTip(
self.ThemeLabel.setText(translate('EditCustomForm', 'Theme:')) translate(u'CustomPlugin.EditCustomForm', u'Edit selected slide'))
self.CreditLabel.setText(translate('EditCustomForm', 'Credits:')) self.EditAllButton.setText(
translate(u'CustomPlugin.EditCustomForm', u'Edit All'))
self.EditAllButton.setToolTip(
translate(u'CustomPlugin.EditCustomForm', u'Edit all slides'))
self.SaveButton.setText(
translate(u'CustomPlugin.EditCustomForm', u'Save'))
self.SaveButton.setToolTip(
translate(u'CustomPlugin.EditCustomForm', u'Replace edited slide'))
self.DeleteButton.setText(
translate(u'CustomPlugin.EditCustomForm', u'Delete'))
self.DeleteButton.setToolTip(
translate(u'CustomPlugin.EditCustomForm', u'Delete selected slide'))
self.ClearButton.setText(
translate(u'CustomPlugin.EditCustomForm', u'Clear'))
self.ClearButton.setToolTip(
translate(u'CustomPlugin.EditCustomForm', u'Clear edit area'))
self.SplitButton.setText(
translate(u'CustomPlugin.EditCustomForm', u'Split Slide'))
self.SplitButton.setToolTip(
translate(u'CustomPlugin.EditCustomForm', u'Add slide split'))
self.ThemeLabel.setText(
translate(u'CustomPlugin.EditCustomForm', u'Theme:'))
self.CreditLabel.setText(
translate(u'CustomPlugin.EditCustomForm', u'Credits:'))

View File

@ -47,7 +47,8 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
self.setupUi(self) self.setupUi(self)
# Connecting signals and slots # Connecting signals and slots
self.previewButton = QtGui.QPushButton() self.previewButton = QtGui.QPushButton()
self.previewButton.setText(translate('editCustomForm','Save && Preview')) self.previewButton.setText(translate(u'CustomPlugin.EditCustomForm',
u'Save && Preview'))
self.buttonBox.addButton( self.buttonBox.addButton(
self.previewButton, QtGui.QDialogButtonBox.ActionRole) self.previewButton, QtGui.QDialogButtonBox.ActionRole)
QtCore.QObject.connect(self.buttonBox, QtCore.QObject.connect(self.buttonBox,
@ -84,7 +85,8 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
def onPreview(self, button): def onPreview(self, button):
log.debug(u'onPreview') log.debug(u'onPreview')
if button.text() == unicode(translate('editCustomForm','Save && Preview')) \ if button.text() == unicode(translate(u'CustomPlugin.EditCustomForm',
u'Save && Preview')) \
and self.saveCustom(): and self.saveCustom():
Receiver.send_message(u'custom_preview') Receiver.send_message(u'custom_preview')
@ -147,7 +149,8 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
def saveCustom(self): def saveCustom(self):
valid, message = self._validate() valid, message = self._validate()
if not valid: if not valid:
QtGui.QMessageBox.critical(self, translate('editCustomForm','Error'), message, QtGui.QMessageBox.critical(self,
translate(u'CustomPlugin.EditCustomForm', u'Error'), message,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
return False return False
sxml = SongXMLBuilder() sxml = SongXMLBuilder()
@ -263,12 +266,15 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
def _validate(self): def _validate(self):
if len(self.TitleEdit.displayText()) == 0: if len(self.TitleEdit.displayText()) == 0:
self.TitleEdit.setFocus() self.TitleEdit.setFocus()
return False, translate('editCustomForm','You need to enter a title') return False, translate(u'CustomPlugin.EditCustomForm',
u'You need to enter a title')
# must have 1 slide # must have 1 slide
if self.VerseListView.count() == 0: if self.VerseListView.count() == 0:
self.VerseTextEdit.setFocus() self.VerseTextEdit.setFocus()
return False, translate('editCustomForm','You need to enter a slide') return False, translate(u'CustomPlugin.EditCustomForm',
u'You need to enter a slide')
if self.VerseTextEdit.toPlainText(): if self.VerseTextEdit.toPlainText():
self.VerseTextEdit.setFocus() self.VerseTextEdit.setFocus()
return False, translate('editCustomForm','You have unsaved data, please save or clear') return False, translate(u'CustomPlugin.editCustomForm',
u'You have unsaved data, please save or clear')
return True, u'' return True, u''

View File

@ -36,7 +36,7 @@ class CustomTab(SettingsTab):
def setupUi(self): def setupUi(self):
self.setObjectName(u'CustomTab') self.setObjectName(u'CustomTab')
self.tabTitleVisible = translate('CustomTab','Custom') self.tabTitleVisible = translate(u'CustomPlugin.CustomTab', u'Custom')
self.CustomLayout = QtGui.QFormLayout(self) self.CustomLayout = QtGui.QFormLayout(self)
self.CustomLayout.setObjectName(u'CustomLayout') self.CustomLayout.setObjectName(u'CustomLayout')
self.CustomModeGroupBox = QtGui.QGroupBox(self) self.CustomModeGroupBox = QtGui.QGroupBox(self)
@ -55,9 +55,10 @@ class CustomTab(SettingsTab):
self.onDisplayFooterCheckBoxChanged) self.onDisplayFooterCheckBoxChanged)
def retranslateUi(self): def retranslateUi(self):
self.CustomModeGroupBox.setTitle(translate('CustomTab','Custom Display')) self.CustomModeGroupBox.setTitle(translate(u'CustomPlugin.CustomTab',
u'Custom Display'))
self.DisplayFooterCheckBox.setText( self.DisplayFooterCheckBox.setText(
translate('CustomTab','Display Footer')) translate(u'CustomPlugin.CustomTab', u'Display Footer'))
def onDisplayFooterCheckBoxChanged(self, check_state): def onDisplayFooterCheckBoxChanged(self, check_state):
self.displayFooter = False self.displayFooter = False

View File

@ -66,7 +66,7 @@ class CustomMediaItem(MediaManagerItem):
QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick) QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick)
def initPluginNameVisible(self): def initPluginNameVisible(self):
self.PluginNameVisible = translate('mediaItem','Custom') self.PluginNameVisible = translate(u'CustomPlugin.MediaItem', u'Custom')
def requiredIcons(self): def requiredIcons(self):
MediaManagerItem.requiredIcons(self) MediaManagerItem.requiredIcons(self)

View File

@ -56,11 +56,12 @@ class ImagePlugin(Plugin):
return ImageMediaItem(self, self.icon, self.name) return ImageMediaItem(self, self.icon, self.name)
def about(self): def about(self):
about_text = translate('ImagePlugin','<b>Image Plugin</b><br>Allows images of ' about_text = translate(u'ImagePlugin.ImagePlugin', u'<b>Image Plugin'
'all types to be displayed. If a number of images are selected ' u'</b><br>Allows images of all types to be displayed. If a number '
'together and presented on the live controller it is possible ' u'of images are selected together and presented on the live '
'to turn them into a timed loop.<br<br>From the plugin if the ' u'controller it is possible to turn them into a timed loop.<br<br>'
'<i>Override background</i> is chosen and an image is selected ' u'From the plugin if the <i>Override background</i> is chosen and '
'any songs which are rendered will use the selected image from ' u'an image is selected any songs which are rendered will use the '
'the background instead of the one provied by the theme.<br>') u'selected image from the background instead of the one provied by '
u'the theme.<br>')
return about_text return about_text

View File

@ -36,7 +36,7 @@ class ImageTab(SettingsTab):
def setupUi(self): def setupUi(self):
self.setObjectName(u'ImageTab') self.setObjectName(u'ImageTab')
self.tabTitleVisible = translate('ImageTab','Images') self.tabTitleVisible = translate(u'ImagePlugin.ImageTab', u'Images')
self.ImageLayout = QtGui.QFormLayout(self) self.ImageLayout = QtGui.QFormLayout(self)
self.ImageLayout.setObjectName(u'ImageLayout') self.ImageLayout.setObjectName(u'ImageLayout')
self.ImageSettingsGroupBox = QtGui.QGroupBox(self) self.ImageSettingsGroupBox = QtGui.QGroupBox(self)
@ -63,9 +63,12 @@ class ImageTab(SettingsTab):
QtCore.SIGNAL(u'valueChanged(int)'), self.onTimeoutSpinBoxChanged) QtCore.SIGNAL(u'valueChanged(int)'), self.onTimeoutSpinBoxChanged)
def retranslateUi(self): def retranslateUi(self):
self.ImageSettingsGroupBox.setTitle(translate('ImageTab','Image Settings')) self.ImageSettingsGroupBox.setTitle(
self.TimeoutLabel.setText(translate('ImageTab','Slide Loop Delay:')) translate(u'ImagePlugin.ImageTab', u'Image Settings'))
self.TimeoutSpinBox.setSuffix(translate('ImageTab','sec')) self.TimeoutLabel.setText(
translate(u'ImagePlugin.ImageTab', u'Slide Loop Delay:'))
self.TimeoutSpinBox.setSuffix(
translate(u'ImagePlugin.ImageTab', u'sec'))
def onTimeoutSpinBoxChanged(self): def onTimeoutSpinBoxChanged(self):
self.loop_delay = self.TimeoutSpinBox.value() self.loop_delay = self.TimeoutSpinBox.value()

View File

@ -56,12 +56,13 @@ class ImageMediaItem(MediaManagerItem):
MediaManagerItem.__init__(self, parent, icon, title) MediaManagerItem.__init__(self, parent, icon, title)
def initPluginNameVisible(self): def initPluginNameVisible(self):
self.PluginNameVisible = translate('MediaItem','Image') self.PluginNameVisible = translate(u'ImagePlugin.MediaItem', u'Image')
def retranslateUi(self): def retranslateUi(self):
self.OnNewPrompt = translate('MediaItem','Select Image(s)') self.OnNewPrompt = translate(u'ImagePlugin.MediaItem',
self.OnNewFileMasks = translate('MediaItem', u'Select Image(s)')
'Images (*.jpg *.jpeg *.gif *.png *.bmp);; All files (*)') self.OnNewFileMasks = translate(u'ImagePlugin.MediaItem',
u'Images (*.jpg *.jpeg *.gif *.png *.bmp);; All files (*)')
def requiredIcons(self): def requiredIcons(self):
MediaManagerItem.requiredIcons(self) MediaManagerItem.requiredIcons(self)
@ -90,7 +91,7 @@ class ImageMediaItem(MediaManagerItem):
self.ListView.addAction( self.ListView.addAction(
contextMenuAction( contextMenuAction(
self.ListView, u':/slides/slide_blank.png', self.ListView, u':/slides/slide_blank.png',
translate('MediaItem','Replace Live Background'), translate(u'ImagePlugin.MediaItem', u'Replace Live Background'),
self.onReplaceClick)) self.onReplaceClick))
def addEndHeaderBar(self): def addEndHeaderBar(self):
@ -105,7 +106,8 @@ class ImageMediaItem(MediaManagerItem):
self.ImageWidget.setObjectName(u'ImageWidget') self.ImageWidget.setObjectName(u'ImageWidget')
self.blankButton = self.Toolbar.addToolbarButton( self.blankButton = self.Toolbar.addToolbarButton(
u'Replace Background', u':/slides/slide_blank.png', u'Replace Background', u':/slides/slide_blank.png',
translate('MediaItem','Replace Live Background'), self.onReplaceClick, False) translate(u'ImagePlugin.MediaItem', u'Replace Live Background'),
self.onReplaceClick, False)
# Add the song widget to the page layout # Add the song widget to the page layout
self.PageLayout.addWidget(self.ImageWidget) self.PageLayout.addWidget(self.ImageWidget)
@ -143,7 +145,8 @@ class ImageMediaItem(MediaManagerItem):
def generateSlideData(self, service_item, item=None): def generateSlideData(self, service_item, item=None):
items = self.ListView.selectedIndexes() items = self.ListView.selectedIndexes()
if items: if items:
service_item.title = unicode(translate('MediaItem','Image(s)')) service_item.title = unicode(
translate(u'ImagePlugin.MediaItem', u'Image(s)'))
service_item.add_capability(ItemCapabilities.AllowsMaintain) service_item.add_capability(ItemCapabilities.AllowsMaintain)
service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsPreview)
service_item.add_capability(ItemCapabilities.AllowsLoop) service_item.add_capability(ItemCapabilities.AllowsLoop)
@ -161,8 +164,8 @@ class ImageMediaItem(MediaManagerItem):
def onReplaceClick(self): def onReplaceClick(self):
if not self.ListView.selectedIndexes(): if not self.ListView.selectedIndexes():
QtGui.QMessageBox.information(self, QtGui.QMessageBox.information(self,
translate('MediaItem','No item selected'), translate(u'ImagePlugin.MediaItem', u'No item selected'),
translate('MediaItem','You must select one item')) translate(u'ImagePlugin.MediaItem', u'You must select one item'))
items = self.ListView.selectedIndexes() items = self.ListView.selectedIndexes()
for item in items: for item in items:
bitem = self.ListView.item(item.row()) bitem = self.ListView.item(item.row())