mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Edit Book: Fix error when checking spelling if one of the files in the book declares an invalid (empty) language code. Fixes #1316170 [Spellcheck doesn't like ...xml:lang=""](https://bugs.launchpad.net/calibre/+bug/1316170)
This commit is contained in:
parent
a0f94d0c5b
commit
c33dd12449
@ -128,11 +128,17 @@ def read_words_from_html_tag(tag, words, file_name, parent_locale, locale):
|
||||
|
||||
def locale_from_tag(tag):
|
||||
if 'lang' in tag.attrib:
|
||||
loc = parse_lang_code(tag.get('lang'))
|
||||
try:
|
||||
loc = parse_lang_code(tag.get('lang'))
|
||||
except ValueError:
|
||||
loc = None
|
||||
if loc is not None:
|
||||
return loc
|
||||
if '{http://www.w3.org/XML/1998/namespace}lang' in tag.attrib:
|
||||
loc = parse_lang_code(tag.get('{http://www.w3.org/XML/1998/namespace}lang'))
|
||||
try:
|
||||
loc = parse_lang_code(tag.get('{http://www.w3.org/XML/1998/namespace}lang'))
|
||||
except ValueError:
|
||||
loc = None
|
||||
if loc is not None:
|
||||
return loc
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user