Edit book: Fix importing a list of words into a user dictionary not working. Fixes #2064887 [Import of words into dictionary fails](https://bugs.launchpad.net/calibre/+bug/2064887)

This commit is contained in:
Kovid Goyal 2024-05-06 09:19:08 +05:30
parent 6d9d698ab2
commit bf4b7357dd
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 3 deletions

View File

@ -493,8 +493,8 @@ class ManageUserDictionaries(Dialog):
'You must specify a language to import words'), show=True)
words = set(filter(None, [x.strip() for x in str(w.toPlainText()).splitlines()]))
lang = lc[0]
words = {(w, lang) for w in words} - self.current_dictionary.words
if dictionaries.add_to_user_dictionary(self.current_dictionary.name, words, DictionaryLocale(lang, None)):
words_with_lang = {(w, lang) for w in words} - self.current_dictionary.words
if dictionaries.add_to_user_dictionary(self.current_dictionary.name, words_with_lang, DictionaryLocale(lang, None)):
dictionaries.clear_caches()
self.show_current_dictionary()
self.dictionaries_changed = True

View File

@ -291,7 +291,7 @@ class Dictionaries:
wl = len(ud.words)
if isinstance(word, (set, frozenset)):
ud.words |= word
self.add_user_words(word, locale.langcode)
self.add_user_words({x[0] for x in word}, locale.langcode)
else:
ud.words.add((word, locale.langcode))
self.add_user_words((word,), locale.langcode)