forked from openlp/openlp
Use localized booknames instead of English in BookNameForm (used by BibleImportWizard and BibleUpgradeWizard)
bzr-revno: 1948
This commit is contained in:
commit
a9fea228ee
@ -90,7 +90,7 @@ class Ui_BookNameDialog(object):
|
||||
'Select Book Name'))
|
||||
self.infoLabel.setText(translate('BiblesPlugin.BookNameDialog',
|
||||
'The following book name cannot be matched up internally. Please '
|
||||
'select the corresponding English name from the list.'))
|
||||
'select the corresponding name from the list.'))
|
||||
self.currentLabel.setText(translate('BiblesPlugin.BookNameDialog',
|
||||
'Current name:'))
|
||||
self.correspondingLabel.setText(translate(
|
||||
|
@ -28,6 +28,7 @@
|
||||
Module implementing BookNameForm.
|
||||
"""
|
||||
import logging
|
||||
import re
|
||||
|
||||
from PyQt4.QtGui import QDialog
|
||||
from PyQt4 import QtCore
|
||||
@ -36,6 +37,7 @@ from openlp.core.lib import translate
|
||||
from openlp.core.lib.ui import critical_error_message_box
|
||||
from openlp.plugins.bibles.forms.booknamedialog import \
|
||||
Ui_BookNameDialog
|
||||
from openlp.plugins.bibles.lib import BibleStrings
|
||||
from openlp.plugins.bibles.lib.db import BiblesResourcesDB
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -54,6 +56,8 @@ class BookNameForm(QDialog, Ui_BookNameDialog):
|
||||
QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
self.customSignals()
|
||||
self.booknames = BibleStrings().Booknames
|
||||
self.book_id = False
|
||||
|
||||
def customSignals(self):
|
||||
"""
|
||||
@ -97,7 +101,8 @@ class BookNameForm(QDialog, Ui_BookNameDialog):
|
||||
and item[u'testament_id'] == 3:
|
||||
addBook = False
|
||||
if addBook:
|
||||
self.correspondingComboBox.addItem(item[u'name'])
|
||||
self.correspondingComboBox.addItem(
|
||||
self.booknames[item[u'abbreviation']])
|
||||
|
||||
def exec_(self, name, books, maxbooks):
|
||||
self.books = books
|
||||
@ -120,4 +125,13 @@ class BookNameForm(QDialog, Ui_BookNameDialog):
|
||||
self.correspondingComboBox.setFocus()
|
||||
return False
|
||||
else:
|
||||
cor_book = unicode(self.correspondingComboBox.currentText())
|
||||
for character in u'\\.^$*+?{}[]()':
|
||||
cor_book = cor_book.replace(character, u'\\' + character)
|
||||
books = filter(lambda key:
|
||||
re.match(cor_book, unicode(self.booknames[key]), re.UNICODE),
|
||||
self.booknames.keys())
|
||||
books = filter(None, map(BiblesResourcesDB.get_book, books))
|
||||
if books:
|
||||
self.book_id = books[0][u'id']
|
||||
return QDialog.accept(self)
|
||||
|
@ -332,6 +332,7 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
def get_book_ref_id_by_name(self, book, maxbooks, language_id=None):
|
||||
log.debug(u'BibleDB.get_book_ref_id_by_name:("%s", "%s")', book,
|
||||
language_id)
|
||||
book_id = None
|
||||
if BiblesResourcesDB.get_book(book, True):
|
||||
book_temp = BiblesResourcesDB.get_book(book, True)
|
||||
book_id = book_temp[u'id']
|
||||
@ -341,26 +342,13 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
book_id = AlternativeBookNamesDB.get_book_reference_id(book)
|
||||
else:
|
||||
from openlp.plugins.bibles.forms import BookNameForm
|
||||
book_ref = None
|
||||
book_name = BookNameForm(self.wizard)
|
||||
if book_name.exec_(book, self.get_books(), maxbooks):
|
||||
book_ref = unicode(
|
||||
book_name.correspondingComboBox.currentText())
|
||||
if not book_ref:
|
||||
return None
|
||||
else:
|
||||
book_temp = BiblesResourcesDB.get_book(book_ref)
|
||||
if book_temp:
|
||||
book_id = book_temp[u'id']
|
||||
else:
|
||||
return None
|
||||
book_id = book_name.book_id
|
||||
if book_id:
|
||||
AlternativeBookNamesDB.create_alternative_book_name(
|
||||
book, book_id, language_id)
|
||||
if book_id:
|
||||
return book_id
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_verses(self, reference_list, show_error=True):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user