mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
When adding books that have no language specified, do not automaticallly set the langauge to calibre's interface language. Fixes #830092 (Downloading and adding books causes default language to be assigned)
This commit is contained in:
parent
8812d9eadc
commit
0e4e082ed7
@ -1312,7 +1312,7 @@ class OPFCreator(Metadata):
|
|||||||
ncx_stream.flush()
|
ncx_stream.flush()
|
||||||
|
|
||||||
|
|
||||||
def metadata_to_opf(mi, as_string=True):
|
def metadata_to_opf(mi, as_string=True, default_lang=None):
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
import textwrap
|
import textwrap
|
||||||
from calibre.ebooks.oeb.base import OPF, DC
|
from calibre.ebooks.oeb.base import OPF, DC
|
||||||
@ -1328,7 +1328,8 @@ def metadata_to_opf(mi, as_string=True):
|
|||||||
'[http://calibre-ebook.com]'
|
'[http://calibre-ebook.com]'
|
||||||
|
|
||||||
if not mi.languages:
|
if not mi.languages:
|
||||||
lang = get_lang().replace('_', '-').partition('-')[0]
|
lang = (get_lang().replace('_', '-').partition('-')[0] if default_lang
|
||||||
|
is None else default_lang)
|
||||||
mi.languages = [lang]
|
mi.languages = [lang]
|
||||||
|
|
||||||
root = etree.fromstring(textwrap.dedent(
|
root = etree.fromstring(textwrap.dedent(
|
||||||
|
@ -33,7 +33,7 @@ def serialize_metadata_for(formats, tdir, id_):
|
|||||||
if not mi.application_id:
|
if not mi.application_id:
|
||||||
mi.application_id = '__calibre_dummy__'
|
mi.application_id = '__calibre_dummy__'
|
||||||
with open(os.path.join(tdir, '%s.opf'%id_), 'wb') as f:
|
with open(os.path.join(tdir, '%s.opf'%id_), 'wb') as f:
|
||||||
f.write(metadata_to_opf(mi))
|
f.write(metadata_to_opf(mi, default_lang='und'))
|
||||||
if cdata:
|
if cdata:
|
||||||
with open(os.path.join(tdir, str(id_)), 'wb') as f:
|
with open(os.path.join(tdir, str(id_)), 'wb') as f:
|
||||||
f.write(cdata)
|
f.write(cdata)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user