When converting books using the calibre GUI, set the language of the output book to be the same as the language of the User Interface, instead of undefined.

This commit is contained in:
Kovid Goyal 2010-06-22 11:40:59 -06:00
parent 1e260bd0e3
commit de427391d3
2 changed files with 9 additions and 4 deletions

View File

@ -282,7 +282,7 @@ class MetaInformation(object):
for attr in ('author_sort', 'title_sort', 'category',
'publisher', 'series', 'series_index', 'rating',
'isbn', 'application_id', 'manifest', 'spine', 'toc',
'cover', 'language', 'guide', 'book_producer',
'cover', 'guide', 'book_producer',
'timestamp', 'lccn', 'lcc', 'ddc', 'pubdate', 'rights',
'publication_type', 'uuid'):
if hasattr(mi, attr):
@ -314,6 +314,11 @@ class MetaInformation(object):
if len(other_comments.strip()) > len(my_comments.strip()):
self.comments = other_comments
other_lang = getattr(mi, 'language', None)
if other_lang and other_lang.lower() != 'und':
self.language = other_lang
def format_series_index(self):
try:
x = float(self.series_index)

View File

@ -18,7 +18,7 @@ from calibre.constants import __appname__, __version__, filesystem_encoding
from calibre.ebooks.metadata.toc import TOC
from calibre.ebooks.metadata import MetaInformation, string_to_authors
from calibre.utils.date import parse_date, isoformat
from calibre.utils.localization import get_lang
class Resource(object):
'''
@ -1069,7 +1069,7 @@ class OPFCreator(MetaInformation):
dc_attrs={'id':__appname__+'_id'}))
if getattr(self, 'pubdate', None) is not None:
a(DC_ELEM('date', self.pubdate.isoformat()))
a(DC_ELEM('language', self.language if self.language else 'UND'))
a(DC_ELEM('language', self.language if self.language else get_lang()))
if self.comments:
a(DC_ELEM('description', self.comments))
if self.publisher:
@ -1184,7 +1184,6 @@ def metadata_to_opf(mi, as_string=True):
factory(DC('contributor'), mi.book_producer, __appname__, 'bkp')
if hasattr(mi.pubdate, 'isoformat'):
factory(DC('date'), isoformat(mi.pubdate))
factory(DC('language'), mi.language)
if mi.category:
factory(DC('type'), mi.category)
if mi.comments:
@ -1195,6 +1194,7 @@ def metadata_to_opf(mi, as_string=True):
factory(DC('identifier'), mi.isbn, scheme='ISBN')
if mi.rights:
factory(DC('rights'), mi.rights)
factory(DC('language'), mi.language if mi.language and mi.language.lower() != 'und' else get_lang())
if mi.tags:
for tag in mi.tags:
factory(DC('subject'), tag)