Set InDesign spelling and hyphenation dictionaries using Javascript
First time to post to the the forums.
I am trying to create a script that, among other things, sets the spelling and hyphenation dictionaries of a document to Hunspell. I can't seem to figure out how to address the right piece of the object model to change the dictionaries. I started with the Dictionary portion of Keith Gilbert's InDesign Preferences script and tried to strip out the bits that don't appear to apply to my specific situation, which ends up looking like this:
var myDoc = app.activeDocument;
myDoc.textDefaults.appliedLanguage = "English: USA";
// app.languagesWithVendors.itemByName('English: USA').addDictionaryPath(File('~/Library/Application Support/Adobe/Linguistics/UserDictionaries/Adobe Custom Dictionary/en_US'));
// var fullPathOfUDC = "<user disctionary path>";
// if (File(fullPathOfUDC).exists) {
var languages = app.languagesWithVendors.everyItem().getElements();
for (var n=0; n<languages.length; n++) {
if (languages
.name == app.translateKeyString("$ID/English: USA")) { // var result = languages
.addDictionaryPath(fullPathOfUDC); languages
.hyphenationVendor = "Hunspell"; languages
.spellingVendor = "Hunspell"; // languages
.doubleQuotes = ; // languages
.singleQuotes = ; }
}
// }
Didn't work.
I then tried a number of variations that tried addressing the objects directly, like this:
app.languagesWithVendors.itemByName('English: USA').hyphenationVendor = "Hunspell";
app.languagesWithVendors.itemByName('English: USA').spellingVendor = "Hunspell";
That didn't work either. Obviously I don't really understand the object model.
I found another discussion asking about the same situation, but it didn't look like there was a satisfactory answer.
Can anyone point me in the right direction? Just trying to solve a problem and learn some stuff in the process.
Thanks in advance for any help you're able to provide!
