mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
MOBI metadata: When setting the language in a MOBI file also update the language field in the EXTH header. Fixes #1154351 (Command line unable to set language)
This commit is contained in:
parent
03f8447a10
commit
67903b743a
@ -18,6 +18,7 @@ from calibre.ebooks.mobi import MobiError, MAX_THUMB_DIMEN
|
||||
from calibre.ebooks.mobi.utils import rescale_image
|
||||
from calibre.ebooks.mobi.langcodes import iana2mobi
|
||||
from calibre.utils.date import now as nowf
|
||||
from calibre.utils.localization import canonicalize_lang, lang_as_iso639_1
|
||||
|
||||
def is_image(ss):
|
||||
if ss is None:
|
||||
@ -401,6 +402,13 @@ class MetadataUpdater(object):
|
||||
if getattr(mi, 'book_producer', False):
|
||||
update_exth_record((108, mi.book_producer.encode(self.codec, 'replace')))
|
||||
|
||||
# Set langcode in EXTH header
|
||||
if not mi.is_null('language'):
|
||||
lang = canonicalize_lang(mi.language)
|
||||
lang = lang_as_iso639_1(lang) or lang
|
||||
if lang:
|
||||
update_exth_record((524, lang.encode(self.codec, 'replace')))
|
||||
|
||||
# Include remaining original EXTH fields
|
||||
for id in sorted(self.original_exth_records):
|
||||
recs.append((id, self.original_exth_records[id]))
|
||||
|
Loading…
x
Reference in New Issue
Block a user