Fix mediaitem.pys i18n

This commit is contained in:
Jon Tibble 2009-10-28 01:36:24 +00:00
parent fe625ee1ff
commit 2eccd57aca
8 changed files with 52 additions and 35 deletions

View File

@ -62,14 +62,19 @@ class MediaManagerItem(QtGui.QWidget):
This sets the translation context of all the text in the
Media Manager item.
``self.PluginTextShort``
The shortened name for the plugin, e.g. *'Image'* for the
image plugin.
``self.PluginNameShort``
The shortened (usually singular) name for the plugin e.g. *'Song'*
for the Songs plugin.
``self.PluginNameVisible``
The user visible name for a plugin which should use a suitable
translation function. This should normally be
``self.trUtf8(self.PluginNameShort)``.
``self.ConfigSection``
The section in the configuration where the items in the media
manager are stored. This could potentially be
``self.PluginTextShort.lower()``.
``self.PluginNameShort.lower()``.
``self.OnNewPrompt``
Defaults to *'Select Image(s)'*.
@ -116,6 +121,8 @@ class MediaManagerItem(QtGui.QWidget):
self.PageLayout.setSpacing(0)
self.PageLayout.setContentsMargins(4, 0, 4, 0)
self.requiredIcons()
def finishInit(self):
self.setupUi()
self.retranslateUi()
@ -204,51 +211,51 @@ class MediaManagerItem(QtGui.QWidget):
## File Button ##
if self.hasFileIcon:
self.addToolbarButton(
u'%s %s' % (self.trUtf8(u'Load'), self.PluginTextShort),
u'%s %s' % (self.trUtf8(u'Load a new'), self.PluginTextShort),
u'Load %s' % self.PluginNameShort,
u'%s %s' % (self.trUtf8(u'Load a new'), self.PluginNameVisible),
u':%s_load.png' % self.IconPath, self.onFileClick,
u'%sFileItem' % self.PluginTextShort)
u'%sFileItem' % self.PluginNameShort)
## New Button ##
if self.hasNewIcon:
self.addToolbarButton(
u'%s %s' % (self.trUtf8(u'New'), self.PluginTextShort),
u'%s %s' % (self.trUtf8(u'Add a new'), self.PluginTextShort),
u'New %s' % self.PluginNameShort,
u'%s %s' % (self.trUtf8(u'Add a new'), self.PluginNameVisible),
u':%s_new.png' % self.IconPath, self.onNewClick,
u'%sNewItem' % self.PluginTextShort)
u'%sNewItem' % self.PluginNameShort)
## Edit Button ##
if self.hasEditIcon:
self.addToolbarButton(
u'%s %s' % (self.trUtf8(u'Edit'), self.PluginTextShort),
u'%s %s' % (self.trUtf8(u'Edit the selected'), self.PluginTextShort),
u'Edit %s' % self.PluginNameShort,
u'%s %s' % (self.trUtf8(u'Edit the selected'), self.PluginNameVisible),
u':%s_edit.png' % self.IconPath, self.onEditClick,
u'%sEditItem' % self.PluginTextShort)
u'%sEditItem' % self.PluginNameShort)
## Delete Button ##
if self.hasDeleteIcon:
self.addToolbarButton(
u'%s %s' % (self.trUtf8(u'Delete'), self.PluginTextShort),
u'Delete %s' % self.PluginNameShort,
self.trUtf8(u'Delete the selected item'),
u':%s_delete.png' % self.IconPath, self.onDeleteClick,
u'%sDeleteItem' % self.PluginTextShort)
u'%sDeleteItem' % self.PluginNameShort)
## Separator Line ##
self.addToolbarSeparator()
## Preview ##
self.addToolbarButton(
u'%s %s' % (self.trUtf8(u'Preview'), self.PluginTextShort),
u'Preview %s' % self.PluginNameShort,
self.trUtf8(u'Preview the selected item'),
u':/system/system_preview.png', self.onPreviewClick,
u'PreviewItem')
## Live Button ##
self.addToolbarButton(
self.trUtf8(u'Go Live'),
u'Go Live',
self.trUtf8(u'Send the selected item live'),
u':/system/system_live.png', self.onLiveClick,
u'LiveItem')
## Add to service Button ##
self.addToolbarButton(
u'%s %s %s' % (self.trUtf8(u'Add'), self.trUtf8(u'to Service'), self.PluginTextShort),
u'%s %s %s' % (u'Add', self.PluginNameShort, u'to Service'),
self.trUtf8(u'Add the selected item(s) to the service'),
u':/system/system_add.png', self.onAddClick,
u'%sAddServiceItem' % self.PluginTextShort)
u'%sAddServiceItem' % self.PluginNameShort)
def addListViewToToolBar(self):
#Add the List widget
@ -260,7 +267,7 @@ class MediaManagerItem(QtGui.QWidget):
QtGui.QAbstractItemView.ExtendedSelection)
self.ListView.setAlternatingRowColors(True)
self.ListView.setDragEnabled(True)
self.ListView.setObjectName(u'%sListView' % self.PluginTextShort)
self.ListView.setObjectName(u'%sListView' % self.PluginNameShort)
#Add tp PageLayout
self.PageLayout.addWidget(self.ListView)
#define and add the context menu
@ -269,13 +276,13 @@ class MediaManagerItem(QtGui.QWidget):
self.ListView.addAction(
contextMenuAction(
self.ListView, u':%s_new.png' % self.IconPath,
u'%s %s' % (self.trUtf8(u'&Edit'), self.PluginTextShort),
u'%s %s' % (self.trUtf8(u'&Edit'), self.PluginNameVisible),
self.onEditClick))
self.ListView.addAction(contextMenuSeparator(self.ListView))
self.ListView.addAction(
contextMenuAction(
self.ListView, u':/system/system_preview.png',
u'%s %s' % (self.trUtf8(u'&Preview'), self.PluginTextShort),
u'%s %s' % (self.trUtf8(u'&Preview'), self.PluginNameVisible),
self.onPreviewClick))
self.ListView.addAction(
contextMenuAction(
@ -351,19 +358,19 @@ class MediaManagerItem(QtGui.QWidget):
u'to be defined by the plugin')
def onPreviewClick(self):
log.debug(self.PluginTextShort + u' Preview Requested')
log.debug(self.PluginNameShort + u' Preview Requested')
service_item = self.buildServiceItem()
if service_item is not None:
self.parent.preview_controller.addServiceItem(service_item)
def onLiveClick(self):
log.debug(self.PluginTextShort + u' Live Requested')
log.debug(self.PluginNameShort + u' Live Requested')
service_item = self.buildServiceItem()
if service_item is not None:
self.parent.live_controller.addServiceItem(service_item)
def onAddClick(self):
log.debug(self.PluginTextShort + u' Add Requested')
log.debug(self.PluginNameShort + u' Add Requested')
service_item = self.buildServiceItem()
if service_item is not None:
self.parent.service_manager.addServiceItem(service_item)
@ -374,7 +381,7 @@ class MediaManagerItem(QtGui.QWidget):
"""
service_item = ServiceItem(self.parent)
service_item.addIcon(
u':/media/media_' + self.PluginTextShort.lower() + u'.png')
u':/media/media_' + self.PluginNameShort.lower() + u'.png')
if self.generateSlideData(service_item):
self.ListView.clearSelection()
return service_item

View File

@ -44,9 +44,7 @@ class SettingsTab(QtGui.QWidget):
to write to when the ``save`` method is called.
"""
QtGui.QWidget.__init__(self)
self.tabTitle = self.trUtf8(title)
# Use the line below when pulling the translation template file.
#self.tabTitle = title
self.tabTitle = title
self.setupUi()
self.retranslateUi()
self.initialise()

View File

@ -47,13 +47,15 @@ class BibleMediaItem(MediaManagerItem):
def __init__(self, parent, icon, title):
self.TranslationContext = u'BiblePlugin'
self.PluginTextShort = u'Bible'
self.PluginNameShort = u'Bible'
self.ConfigSection = u'bibles'
self.IconPath = u'songs/song'
self.ListViewWithDnD_class = BibleListView
self.ServiceItemIconName = u':/media/bible_image.png'
self.servicePath = None
MediaManagerItem.__init__(self, parent, icon, title)
self.PluginNameVisible = self.trUtf8(self.PluginNameShort)
self.finishInit()
# place to store the search results
self.search_results = {}
QtCore.QObject.connect(Receiver().get_receiver(),

View File

@ -43,7 +43,7 @@ class CustomMediaItem(MediaManagerItem):
def __init__(self, parent, icon, title):
self.TranslationContext = u'CustomPlugin'
self.PluginTextShort = u'Custom'
self.PluginNameShort = u'Custom'
self.ConfigSection = u'custom'
self.IconPath = u'custom/custom'
# this next is a class, not an instance of a class - it will
@ -52,6 +52,8 @@ class CustomMediaItem(MediaManagerItem):
self.ServiceItemIconName = u':/custom/custom_image.png'
self.servicePath = None
MediaManagerItem.__init__(self, parent, icon, title)
self.PluginNameVisible = self.trUtf8(self.PluginNameShort)
self.finishInit()
self.parent = parent
def requiredIcons(self):

View File

@ -45,7 +45,7 @@ class ImageMediaItem(MediaManagerItem):
def __init__(self, parent, icon, title):
self.TranslationContext = u'ImagePlugin'
self.PluginTextShort = u'Image'
self.PluginNameShort = u'Image'
self.ConfigSection = u'images'
self.IconPath = u'images/image'
# this next is a class, not an instance of a class - it will
@ -54,6 +54,8 @@ class ImageMediaItem(MediaManagerItem):
self.ServiceItemIconName = u':/media/media_image.png'
self.servicePath = None
MediaManagerItem.__init__(self, parent, icon, title)
self.PluginNameVisible = self.trUtf8(self.PluginNameShort)
self.finishInit()
self.overrideActive = False
def retranslateUi(self):

View File

@ -44,8 +44,8 @@ class MediaMediaItem(MediaManagerItem):
def __init__(self, parent, icon, title):
self.TranslationContext = u'MediaPlugin'
self.PluginNameShort = u'Media'
self.IconPath = u'images/image'
self.PluginTextShort = u'Media'
self.ConfigSection = u'media'
self.OnNewPrompt = u'Select Media(s)'
self.OnNewFileMasks = \
@ -56,6 +56,8 @@ class MediaMediaItem(MediaManagerItem):
#self.ServiceItemIconName = u':/media/media_image.png'
self.PreviewFunction = self.video_get_preview
MediaManagerItem.__init__(self, parent, icon, title)
self.PluginNameVisible = self.trUtf8(self.PluginNameShort)
self.finishInit()
def requiredIcons(self):
MediaManagerItem.requiredIcons(self)

View File

@ -49,7 +49,7 @@ class PresentationMediaItem(MediaManagerItem):
def __init__(self, parent, icon, title, controllers):
self.controllers = controllers
self.TranslationContext = u'PresentationPlugin'
self.PluginTextShort = u'Presentation'
self.PluginNameShort = u'Presentation'
self.ConfigSection = u'presentations'
self.IconPath = u'presentations/presentation'
self.OnNewPrompt = u'Select Presentation(s)'
@ -58,6 +58,8 @@ class PresentationMediaItem(MediaManagerItem):
# be instanced by the base MediaManagerItem
self.ListViewWithDnD_class = PresentationListView
MediaManagerItem.__init__(self, parent, icon, title)
self.PluginNameVisible = self.trUtf8(self.PluginNameShort)
self.finishInit()
self.message_listener = MessageListener(controllers)
def requiredIcons(self):

View File

@ -45,13 +45,15 @@ class SongMediaItem(MediaManagerItem):
def __init__(self, parent, icon, title):
self.TranslationContext = u'SongPlugin'
self.PluginTextShort = u'Song'
self.PluginNameShort = u'Song'
self.ConfigSection = u'songs'
self.IconPath = u'songs/song'
self.ListViewWithDnD_class = SongListView
self.ServiceItemIconName = u':/media/song_image.png'
self.servicePath = None
MediaManagerItem.__init__(self, parent, icon, title)
self.PluginNameVisible = self.trUtf8(self.PluginNameShort)
self.finishInit()
self.edit_song_form = EditSongForm(self.parent.songmanager, self)
self.song_maintenance_form = SongMaintenanceForm(
self.parent.songmanager, self)