Verse Translations part 2 - revised

This commit is contained in:
Tim Bentley 2010-06-05 21:00:50 +01:00
parent 9d4cb86a6e
commit af3932f182
4 changed files with 59 additions and 66 deletions

View File

@ -23,6 +23,52 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from openlp.core.lib import translate
class VerseType(object):
Verse = 0
Chorus = 1
Bridge = 2
PreChorus = 3
Intro = 4
Ending = 5
Other = 6
@staticmethod
def to_string(verse_type):
if verse_type == VerseType.Verse:
return translate('SongTags', 'Verse')
elif verse_type == VerseType.Chorus:
return translate('SongTags', 'Chorus')
elif verse_type == VerseType.Bridge:
return translate('SongTags', 'Bridge')
elif verse_type == VerseType.PreChorus:
return u'Pre-Chorus'
elif verse_type == VerseType.Intro:
return u'Intro'
elif verse_type == VerseType.Ending:
return u'Ending'
elif verse_type == VerseType.Other:
return u'Other'
@staticmethod
def from_string(verse_type):
verse_type = verse_type.lower()
if verse_type == translate('SongTags', 'verse'):
return VerseType.Verse
elif verse_type == translate('SongTags', 'chorus'):
return VerseType.Chorus
elif verse_type == translate('SongTags', 'bridge'):
return VerseType.Bridge
elif verse_type == u'pre-chorus':
return VerseType.PreChorus
elif verse_type == u'intro':
return VerseType.Intro
elif verse_type == u'ending':
return VerseType.Ending
elif verse_type == u'other':
return VerseType.Other
from authorsform import AuthorsForm from authorsform import AuthorsForm
from topicsform import TopicsForm from topicsform import TopicsForm
from songbookform import SongBookForm from songbookform import SongBookForm

View File

@ -24,8 +24,9 @@
############################################################################### ###############################################################################
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate from openlp.core.lib import translate
from openlp.plugins.songs.lib import TagNames from openlp.plugins.songs.forms import VerseType
class Ui_EditVerseDialog(object): class Ui_EditVerseDialog(object):
def setupUi(self, EditVerseDialog): def setupUi(self, EditVerseDialog):
@ -93,9 +94,9 @@ class Ui_EditVerseDialog(object):
def retranslateUi(self, EditVerseDialog): def retranslateUi(self, EditVerseDialog):
EditVerseDialog.setWindowTitle(translate('EditVerseForm', 'Edit Verse')) EditVerseDialog.setWindowTitle(translate('EditVerseForm', 'Edit Verse'))
self.VerseTypeLabel.setText(translate('EditVerseForm', 'Verse Type:')) self.VerseTypeLabel.setText(translate('EditVerseForm', 'Verse Type:'))
self.VerseTypeComboBox.setItemText(0, TagNames.verse) self.VerseTypeComboBox.setItemText(0, VerseType.to_string(VerseType.Verse))
self.VerseTypeComboBox.setItemText(1, TagNames.chorus) self.VerseTypeComboBox.setItemText(1, VerseType.to_string(VerseType.Chorus))
self.VerseTypeComboBox.setItemText(2, translate('EditVerseForm', 'Bridge')) self.VerseTypeComboBox.setItemText(2, VerseType.to_string(VerseType.Bridge))
self.VerseTypeComboBox.setItemText(3, translate('EditVerseForm', 'Pre-Chorus')) self.VerseTypeComboBox.setItemText(3, translate('EditVerseForm', 'Pre-Chorus'))
self.VerseTypeComboBox.setItemText(4, translate('EditVerseForm', 'Intro')) self.VerseTypeComboBox.setItemText(4, translate('EditVerseForm', 'Intro'))
self.VerseTypeComboBox.setItemText(5, translate('EditVerseForm', 'Ending')) self.VerseTypeComboBox.setItemText(5, translate('EditVerseForm', 'Ending'))

View File

@ -28,56 +28,12 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.plugins.songs.forms import VerseType
from editversedialog import Ui_EditVerseDialog from editversedialog import Ui_EditVerseDialog
from openlp.plugins.songs.lib import TagNames
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class VerseType(object):
Verse = 0
Chorus = 1
Bridge = 2
PreChorus = 3
Intro = 4
Ending = 5
Other = 6
@staticmethod
def to_string(verse_type):
if verse_type == VerseType.Verse:
return TagNames.verse
elif verse_type == VerseType.Chorus:
return TagNames.chorus
elif verse_type == VerseType.Bridge:
return u'Bridge'
elif verse_type == VerseType.PreChorus:
return u'Pre-Chorus'
elif verse_type == VerseType.Intro:
return u'Intro'
elif verse_type == VerseType.Ending:
return u'Ending'
elif verse_type == VerseType.Other:
return u'Other'
@staticmethod
def from_string(verse_type):
verse_type = verse_type.lower()
if verse_type == TagNames.lower_verse:
return VerseType.Verse
elif verse_type == TagNames.lower_chorus:
return VerseType.Chorus
elif verse_type == u'bridge':
return VerseType.Bridge
elif verse_type == u'pre-chorus':
return VerseType.PreChorus
elif verse_type == u'intro':
return VerseType.Intro
elif verse_type == u'ending':
return VerseType.Ending
elif verse_type == u'other':
return VerseType.Other
class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
""" """
This is the form that is used to edit the verses of the song. This is the form that is used to edit the verses of the song.
@ -111,11 +67,13 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
self.VerseTextEdit.insertPlainText(u'\n') self.VerseTextEdit.insertPlainText(u'\n')
verse_type = self.VerseTypeComboBox.currentIndex() verse_type = self.VerseTypeComboBox.currentIndex()
if verse_type == VerseType.Verse: if verse_type == VerseType.Verse:
self.insertVerse('Verse', self.VerseNumberBox.value()) self.insertVerse(VerseType.to_string(VerseType.Verse),
self.VerseNumberBox.value())
elif verse_type == VerseType.Chorus: elif verse_type == VerseType.Chorus:
self.insertVerse('Chorus', self.VerseNumberBox.value()) self.insertVerse(VerseType.to_string(VerseType.Chorus),
self.VerseNumberBox.value())
elif verse_type == VerseType.Bridge: elif verse_type == VerseType.Bridge:
self.insertVerse('Bridge') self.insertVerse(VerseType.to_string(VerseType.Bridge))
elif verse_type == VerseType.PreChorus: elif verse_type == VerseType.PreChorus:
self.insertVerse('Pre-Chorus') self.insertVerse('Pre-Chorus')
elif verse_type == VerseType.Intro: elif verse_type == VerseType.Intro:
@ -172,6 +130,6 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
def getVerseAll(self): def getVerseAll(self):
text = self.VerseTextEdit.toPlainText() text = self.VerseTextEdit.toPlainText()
if not text.startsWith(u'---['): if not text.startsWith(u'---['):
text = u'---[Verse:1]---\n%s' % text text = u'---[%s:1]---\n%s' % (VerseType.to_string(VerseType.Verse), text)
return text return text

View File

@ -23,22 +23,10 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from openlp.core.lib import translate
class TagNames(object):
verse = translate('TagNames','Verse')
chorus = translate('TagNames','Chorus')
lower_verse = translate('TagNames','verse')
lower_chorus = translate('TagNames','chorus')
from manager import SongManager from manager import SongManager
from songstab import SongsTab from songstab import SongsTab
from mediaitem import SongMediaItem from mediaitem import SongMediaItem
from sofimport import SofImport from sofimport import SofImport
from oooimport import OooImport from oooimport import OooImport
from songimport import SongImport from songimport import SongImport
from openlp.core.lib import translate