• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Manage hyphenation exceptions in “All languages” language via scripting

Community Beginner ,
Jul 16, 2023 Jul 16, 2023

Copy link to clipboard

Copied

How do I delete all words added to the “All languages” language in the User Dictionary dialog that were merged into the Document with a script?

 

According to this post such words are stored as hyphenation exceptions and therefore accessible with scripting via app.activeDocument.hyphenationExceptions, but words added to the “All languages” language seems to be the exception. This code displays (in the console) all languages and the number of hyphenation exceptions for each language:

 

var myHyphenations = app.activeDocument.hyphenationExceptions;
var myHyphenationsLength = myHyphenations.length;
for (var i = 0; i < myHyphenationsLength; i++ ) {
	myHyphenation = myHyphenations[i];
	var myAddedWords = myHyphenation.addedExceptions;
	$.write(myHyphenation.name + ": " + myAddedWords.length + "\n");
	// myHyphenation.removeException(myAddedWords);
}

 

which matches what is seen in menu Edit ▸ Spelling ▸ User dictionary ▸ Target: [current doc] for each language listed in the Language drop down menu, except for the “All languages” language. The code above does not account for entries in that language at all, nor lists category even. Are those accessible via scripting at all?

TOPICS
Scripting

Views

238

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 17, 2023 Jul 17, 2023

Copy link to clipboard

Copied

I don't know about this - I don't think there is scripting support for document-specific user dictionaries in InDesign. The scripting capabilities seemingly focus on the application-level dictionary, and accessing the "All languages" language in the User Dictionary dialog specifically is not supported through scripting.

The code you provided is for removing hyphenation exceptions, which are different from the user dictionary words. 

 

But maybe @m1b (sorry can't remember the handle for other scripters) knows how to access this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 18, 2023 Jul 18, 2023

Copy link to clipboard

Copied

quote

I don't think there is scripting support for document-specific user dictionaries in InDesign. […]

The code you provided is for removing hyphenation exceptions, which are different from the user dictionary words.

 

That is not correct. Hyphenation exceptions are but words with hyphenation hints that are stored in a user dictionary:

 

Captura de pantalla 2023-07-18 a las 17.29.35.png

 

 

Deleting words from the documents’ user dictionary via scripting (irrespective of them having or not having hyphenation hints) is what the line commented out at the end of the for loop does, only that it seemingly affects words added to all languages except the “All languages” language.

 

So the key to my question is whether there is indeed no scripting support only for words added to “All languages”.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2023 Jul 18, 2023

Copy link to clipboard

Copied

Ah I see - thanks for clarifying! 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 19, 2023 Jul 19, 2023

Copy link to clipboard

Copied

LATEST

Peeking into an unzipped IMDL, the language of the hyphenation exceptions added to “All Languages” seems to be named “Neutral”:

<HyphenationException … Name="$ID/Neutral"

even though no such HyphenationException is listed when asking for the names of all HyphenationExceptions as in the code above, not when requesting specifically:

app.activeDocument.hyphenationExceptions.itemByName("Neutral")

which is invalid.

I suspect that the seemingly lack of scripting support for that “Neutral” language’s user dictionary might have related the bug reported in this thread by which hyphenationExceptions.itemByName() returns the wrong hyphen..., particularly the one intended +1 as per the collection’s index. I wonder if the +1 is due to “Normal” not being accounted for in some part of the code but not others.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines