Copy link to clipboard
Copied
Indesign javascript object model returns incorrect name for the below line,
app.documents[0].hyphenationExceptions.itemByName("English: UK").name.
It returns,
English: USA.
How it is possible.
Regards,
Dillibabu.
Copy link to clipboard
Copied
Hi @dillibabum29191024 , Looks like the entire collection is off by 1:
$.writeln("Looking for Bulgarian — " + app.documents[0].hyphenationExceptions.itemByName("Bulgarian").name + "\r\r")
var h = app.documents[0].hyphenationExceptions
for (var i = 0; i < h.length; i++){
$.writeln(h[i].name)
};
/* Return
Looking for Bulgarian — Catalan
bn_IN
gu_IN
hi_IN
kn_IN
ml_IN
mr_IN
or_IN
pa_IN
ta_IN
te_IN
Bulgarian
Catalan
Czech
Danish
German: Swiss
de_CH_2006
German: Reformed
de_DE_2006
Greek
English: Canadian
English: UK
English: USA
English: USA Medical
Spanish: Castilian
Estonian
Finnish
French: Canadian
French
Croatian
Hungarian
Italian
Lithuanian
Latvian
Norwegian: Bokmal
Dutch
nl_NL_2005
Norwegian: Nynorsk
Polish
Portuguese: Brazilian
Portuguese: Orthographic Agreement
Portuguese
Romanian
Russian
Slovak
Slovenian
Swedish
Turkish
Ukrainian */
Copy link to clipboard
Copied
As noted in this other thread about hyphenation exceptions added to the “All languages” language, I wonder if this bug is the reason why there seems to not exist scripting support to access only the hyphenation exceptions, even though there is for words added to all other languages. As if some parts of the code did account for the “All languages” language (which inside IDML files it is named “Neutral”) but not others and that's why “the entire collection is off by 1”.
Copy link to clipboard
Copied
I meant to write “…to access only those hyphenation exceptions…”.
Copy link to clipboard
Copied
You might have to write your own function
var hbn = getHEByName("English: UK")
$.writeln(hbn.name)
/**
* Get Hyphenation Exception by Name
* @ param name to get
* @ return hyphenation exception
*
*/
function getHEByName(n){
var h = app.documents[0].hyphenationExceptions;
var he
for (var i = 0; i < h.length; i++){
if (h[i].name == n) {
he = h[i]
}
};
return he
}
Copy link to clipboard
Copied
Thank you. We can write a custom function to get by name. But what is the use of the below,
hyphenationExceptions.itemByName()
I want to mention the above line is working wrong.
Copy link to clipboard
Copied
But what is the use of the below
Looks like a bug
Copy link to clipboard
Copied
Bug confirmed!
Just tested this with my German InDesign 17.3.0 on Windows 10.
Thanks for bringing this up.
The bug should be reported at Adobe InDesign UserVoice:
https://indesign.uservoice.com/forums/913162-adobe-indesign-sdk-scripting-bugs-and-features
Regards,
Uwe Laubender
( Adobe Community Professional )
Copy link to clipboard
Copied
This line will fail with an error:
try{
doc.hyphenationExceptions.itemByName( "Arabic" ).name;
}catch(e)
{
$.writeln( "ERROR: " + e.number +", "+ e.message );
}
// RESULT: "ERROR: 1, name"
Because Arabic is listed as the last entry in the collection of hyphenation exceptions.
At least with my installed German InDesign 2022 version 17.3.0 on Windows 10.
The bug is very old. Can see it already with InDesign CS6 version 8.1.
Regards,
Uwe Laubender
( Adobe Community Professional )