mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Catalogs: Set the language of created catalogs to the calibre interface language instead of English
Fixes #1810936 [Feature: language in metadata of created catalog set to calibre installation language](https://bugs.launchpad.net/calibre/+bug/1810936)
This commit is contained in:
parent
b011cddc4a
commit
32e5760eea
@ -25,6 +25,7 @@ from calibre.utils.formatter import TemplateFormatter
|
||||
from calibre.utils.icu import capitalize, collation_order, sort_key
|
||||
from calibre.utils.img import scale_image
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
from calibre.utils.localization import get_lang, lang_as_iso639_1
|
||||
|
||||
|
||||
class Formatter(TemplateFormatter):
|
||||
@ -4014,19 +4015,22 @@ class CatalogBuilder(object):
|
||||
"""
|
||||
|
||||
self.update_progress_full_step(_("Generating OPF"))
|
||||
lang = get_lang() or 'en'
|
||||
if lang_as_iso639_1(lang):
|
||||
lang = lang_as_iso639_1(lang)
|
||||
|
||||
header = '''
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="calibre_id">
|
||||
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"
|
||||
xmlns:calibre="http://calibre.kovidgoyal.net/2009/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<dc:language>en-US</dc:language>
|
||||
<dc:language>LANG</dc:language>
|
||||
</metadata>
|
||||
<manifest></manifest>
|
||||
<spine toc="ncx"></spine>
|
||||
<guide></guide>
|
||||
</package>
|
||||
'''
|
||||
'''.replace('LANG', lang)
|
||||
# Add the supplied metadata tags
|
||||
soup = BeautifulStoneSoup(header, selfClosingTags=['item', 'itemref', 'meta', 'reference'])
|
||||
metadata = soup.find('metadata')
|
||||
|
Loading…
x
Reference in New Issue
Block a user