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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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