diff --git a/src/calibre/ebooks/metadata/__init__.py b/src/calibre/ebooks/metadata/__init__.py index 690cca511a..4d126fda9d 100644 --- a/src/calibre/ebooks/metadata/__init__.py +++ b/src/calibre/ebooks/metadata/__init__.py @@ -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) diff --git a/src/calibre/ebooks/metadata/opf2.py b/src/calibre/ebooks/metadata/opf2.py index 46924cad1f..579398d3b0 100644 --- a/src/calibre/ebooks/metadata/opf2.py +++ b/src/calibre/ebooks/metadata/opf2.py @@ -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)