|
|
#616 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 29,614
Karma: 212299010
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
|
|
|
|
|
|
|
#617 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,857
Karma: 24222221
Join Date: Dec 2010
Device: Kindle PW2
|
It would be helpful if someone added new functions to bk.hspell that allow the user to load the primary and secondary spellcheck dictionaries.
So far, the only method to get these paths is to parse sigil_v6.ini. For example, you could add loadPrimaryDictionary and loadSecondaryDictionary methods to bk.hspell. If en-US is the primary spellcheck dictinary.: Code:
bk.hspell.loadPrimaryDictionary() Code:
aff_file = r"C:\Program Files\Sigil\hunspell_dictionaries\en_US.aff" dic_file = r"C:\Program Files\Sigil\hunspell_dictionaries\en_US.dic" bk.hspell.loadDictionary(aff_file, dic_file) |
|
|
|
|
|
#618 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,822
Karma: 7500000
Join Date: Nov 2009
Device: many
|
First, the path to the dictionary dirs is already available to the plugins see dictionary_dirs so no reason to hard code them. All available spellcheck languages can be gathered from those dirs.
Code:
class BookContainer(object):
def __init__(self, wrapper, debug=False):
self._debug = debug
self._w = wrapper
self.qp = QuickXHTMLParser()
self.hspell = HunspellChecker(wrapper.get_hunspell_path())
self.dictionary_dirs = wrapper.get_dictionary_dirs()
self._prefs_store = JSONPrefs(wrapper.plugin_dir, wrapper.plugin_name)
Extracting the primary language from the html tag should be trivial. If that does not work for you let me know and we can extend the set of information passed to the plugin even further but it is already pretty long now. Please give that a try first. Last edited by KevinH; 07-18-2026 at 07:49 AM. |
|
|
|
|
|
#619 | |||
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,857
Karma: 24222221
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
Quote:
Quote:
|
|||
|
|
|
|
|
#620 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,822
Karma: 7500000
Join Date: Nov 2009
Device: many
|
No, you misunderstand. It is not difficult, but if the xhtml files do not have lang or xml:lang, then surely the opf can be used to get the language of the text (both primary and secondary from existing dc:language metadata tags) as needed.
So my reluctance is to change a long standing api for something that can be extracted locally from the epub itself and be more accurate that what the user defaulted to. That is what is done inside Sigil when a full spellcheck dialog is used. It uses the actual language tags and fallsback to the opf. Only the on the fly red-squiggly spellcheck version uses primary and secondary for pure speed. I would be happy to create a python snippet to use the opf to determine primary and secondary languages which when combined with the dictionary_dirs list if that would help instead. I am just loathe to change a minimalist interface (designed that way on purpose) to add things that can be derived in better ways inside the plugin (and I do not mean parsing the sigil ini files here). If not, then let me know and I will add that requested interface when I get some free time and it will be available in a future version of Sigil. But it kind of defeats that minimalist design approach to interface to a plugin which is why I was so hesitant. Last edited by KevinH; 07-18-2026 at 11:47 AM. |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Loading Plugin in development | Sladd | Development | 6 | 06-17-2014 06:57 PM |
| Question for plugin development gurus | DiapDealer | Plugins | 2 | 02-04-2012 11:33 PM |
| DR800 Plugin development for DR800/DR1000 | yuri_b | iRex Developer's Corner | 0 | 09-18-2010 09:46 AM |
| Device plugin development | reader42 | Plugins | 10 | 03-29-2010 12:39 PM |
| Calibre plugin development - Newbie problems | minstrel | Plugins | 5 | 04-12-2009 12:44 PM |