http://code.google.com/p/texworks/issues/detail?id=563
Comment 1 by project member st.loeffler, Mar 4, 2012
Sounds intriguing. In r962, I have implemented a couple of functions that should be helpful:
TW.app.reloadSpellchecker() does what the name suggests - it reinitializes the spell checker for all open windows (thereby reloading the dictionaries, among other things)
TW.getDictionaryList(const bool forceReload = false) returns a map ("object" in QtScript terms) of the form "language code => array(filenames)". ATM, array(filenames) has exactly one entry, but this may change in the future. To iterate over the map, use something like
dicts = TW.getDictionaryList(false);
for (d in dicts) {
var lang = d;
var file = dicts[d][0];
}
If forceReload=true, the list of available dictionaries is refreshed (note that this doesn't affect any loaded spell checker, but does rebuild the "Edit > Spelling" menus).
TW.target.spellcheckLanguage is a new property that can be read from (to get the current language) and written to (to set the spell checking language). It's probably easier to use than TW.target.setSpellcheckLanguage().
TW.target.reloadSpellcheckerMenu() is new, but not really useful for scripts (it rebuilds the "Edit > Spelling" menus, but TW.getDictionaryList(true) does that automatically, and otherwise there's not much point in calling it.
Finally, a few words of caution:
* On most *nix systems, the dictionaries are considered system resources and cannot be changed (without acquiring super-user privileges). So adding to the .dic files from a script won't be possible. As a workaround, one could maintain a copy of the dictionaries one uses in a location where they can be edited and use the TW_DICPATH environment variable to point Tw to it.
* There currently is no persistent private word list kept by Tw (there's only the temporary, session-specific word list that is used by the "Ignore word" context menu item). This will hopefully be changed in the future (0.8 is the target), but entails a broader rewrite of the spell checking implementation.
Created with the Personal Edition of HelpNDoc: Free HTML Help documentation generator