refer localized booknames to the corresponding english one

This commit is contained in:
Armin Köhler 2012-04-20 21:14:23 +02:00
parent 83ff347bc9
commit d4eac06935
3 changed files with 15 additions and 16 deletions

View File

@ -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(

View File

@ -28,6 +28,7 @@
Module implementing BookNameForm.
"""
import logging
import re
from PyQt4.QtGui import QDialog
from PyQt4 import QtCore
@ -56,6 +57,7 @@ class BookNameForm(QDialog, Ui_BookNameDialog):
self.setupUi(self)
self.customSignals()
self.booknames = BibleStrings().Booknames
self.book_id = False
def customSignals(self):
"""
@ -123,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)

View File

@ -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
return book_id
def get_verses(self, reference_list, show_error=True):
"""