From bf4b7357ddb67de0cd5e210cd6c13524c66e1a06 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 6 May 2024 09:19:08 +0530 Subject: [PATCH] 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) --- src/calibre/gui2/tweak_book/spell.py | 4 ++-- src/calibre/spell/dictionary.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/tweak_book/spell.py b/src/calibre/gui2/tweak_book/spell.py index 2b7cd96a4b..0b870f0871 100644 --- a/src/calibre/gui2/tweak_book/spell.py +++ b/src/calibre/gui2/tweak_book/spell.py @@ -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 diff --git a/src/calibre/spell/dictionary.py b/src/calibre/spell/dictionary.py index 7e1ecad0c4..8d6f2a26df 100644 --- a/src/calibre/spell/dictionary.py +++ b/src/calibre/spell/dictionary.py @@ -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)