forked from openlp/openlp
fixed bug #1214875 'Importing an OSIS bible always results in English book names'
Fixes: https://launchpad.net/bugs/1214875
This commit is contained in:
parent
5bd7479dca
commit
621ef0b6e6
@ -862,6 +862,26 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
return book[0]
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def get_language_by_id(language_id):
|
||||
"""
|
||||
Return a dict containing the language id, name and code by id.
|
||||
|
||||
``id``
|
||||
The id of the language in the database.
|
||||
"""
|
||||
log.debug(u'BiblesResourcesDB.get_language_by_id(%d)', language_id)
|
||||
language = BiblesResourcesDB.run_sql(u'SELECT id, name, code FROM '
|
||||
u'language WHERE id = ?', (unicode(language_id),))
|
||||
if language:
|
||||
return {
|
||||
u'id': language[0][0],
|
||||
u'name': unicode(language[0][1]),
|
||||
u'code': unicode(language[0][2])
|
||||
}
|
||||
else:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def get_language(name):
|
||||
"""
|
||||
|
@ -34,7 +34,7 @@ import codecs
|
||||
import re
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.core.utils import AppLocation
|
||||
from openlp.core.utils import AppLocation, LanguageManager
|
||||
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -157,12 +157,17 @@ class OSISBible(BibleDB):
|
||||
if last_chapter == 0:
|
||||
self.wizard.progressBar.setMaximum(chapter_count)
|
||||
if last_chapter != chapter:
|
||||
custom_translator = LanguageManager.get_translator(
|
||||
BiblesResourcesDB.get_language_by_id(
|
||||
language_id)['code'])[0]
|
||||
book_name_localized = custom_translator.translate(
|
||||
'BiblesPlugin', book_details[u'name'])
|
||||
if last_chapter != 0:
|
||||
self.session.commit()
|
||||
self.wizard.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.OsisImport', 'Importing %s %s...',
|
||||
'Importing <book name> <chapter>...')) %
|
||||
(book_details[u'name'], chapter))
|
||||
(book_name_localized, chapter))
|
||||
last_chapter = chapter
|
||||
# All of this rigmarol below is because the mod2osis
|
||||
# tool from the Sword library embeds XML in the OSIS
|
||||
|
Loading…
Reference in New Issue
Block a user