Skip to main content
Participant
March 12, 2018
Question

Extendscript: how to addword to indd user dictionary with case sensitive enabled ?

  • March 12, 2018
  • 1 reply
  • 474 views

Hi, I'm working on a javascript program that needs to add non hyphenate words to the user dictionnary.

I'm able to add word to the user dictionary with something like :

   var noCesure =[ "~Crescrire"];

   var myUserDictionnaries = app.userDictionaries;

    for (var i = 0; i < myUserDictionnaries.length; i++)

    {

        if (myUserDictionnaries.name == "Français")

        {

            var mySourceUserDictionary = myUserDictionnaries;

            break

        }

    }

    if (myUserDictionnaries.name == "Français")

    {

        mySourceUserDictionary.addWord(noCesure);

    }

But it adds only "~crescrire" to the dictionary, without the uppercase C letter.

I' know it is possible to have the uppercase C in the GUI interface but I did not find how to enable the "case sensitive" switch using extendscript.

Any idea ?

Regards, Pierre

This topic has been closed for replies.

1 reply

Peter Kahrel
Community Expert
Community Expert
March 13, 2018

The user dictionary's exposure to scripting has always been rudimentary. But that words are always added in lower case must be considered a bug. Please report it here: Adobe InDesign Feedback

It's not possible to change the state of the 'case sensitive' checkbox using ExtendScript.

You could reduce your script to a single line, by the way, no need to cycle through the list of dictionaries looking for a specic one:

app.userDictionaries.item('Français').addWord ([ "~Crescrire"]);

or, to play it a bit safer,

dict = app.userDictionaries.item('Français');

if (dict.isValid) {

  dict.addWord (["~Crescrire"]);

}

P.

pierrattAuthor
Participant
March 13, 2018

Peter, thanks for your answer. I've post a bug request :

Extendscript : impossible to add word to user dictionnary with respect to upper/lower case – Adobe InDesign Feedback

Feel free to vote for it.

In the mean time, i've also tried the local document dictionnary. Something like :

doc.hyphenationExceptions.item("French").addException(["~Crescrire"]);

It adds the word "~Crescrire" to the local document dictionary with the upper cace C

but functionnaly speaking, it does not works because the word "Crescrire" is sometimes hyphenated. Any ides why ?