Copy link to clipboard
Copied
Sometimes when we have converted a CS3 InDesign file to a CS5 InDesign file
it crashes. What we have found is that the language is not correct or there is
no language applied and causes the file to crash.
We need it to be English: USA. Can a script be written to find the language and
change it to English: USA?
Thanks
MJP29
Great. And for others looking to solve this problem, I realize that it may be necessary to change "paragraphStyles" to "allParagraphStyles" if you make use of paragraph style groups. If you don't use the groups, then it should work as given.
Copy link to clipboard
Copied
Sometimes when we have converted a CS3 InDesign file to a CS5 InDesign file
it crashes. What we have found is that the language is not correct or there is
no language applied and causes the file to crash.
I suspect this is a symptom, not a cause, and that changing all the applied languages will not fix the problem.
We need it to be English: USA. Can a script be written to find the language and
change it to English: USA?
Sure, it's just a one-liner. Try this:
app.activeDocument.stories.everyItem().appliedLanguage="English: USA";
Let us know how it works.
Copy link to clipboard
Copied
John:
Thanks!! Works great overall but does not work on the InDesign tables for some reason.
Would there be any way to change the language in styles sheets also.
Thanks
MJP29
Copy link to clipboard
Copied
Yeah, it won't work for footnotes either.
I think this covers you for tables, not sure if there's a shorter one:
app.activeDocument.stories.everyItem().tables.everyItem().
cells.everyItem().texts.everyItem().
appliedLanguage=”English: USA”;
Copy link to clipboard
Copied
John:
Your last script does not work. Getting an error.
Error Number: 8
Error String: Syntax error
MJP29
Copy link to clipboard
Copied
John:
You wrote "I suspect this is a symptom, not a cause, and that changing all the applied languages will not fix the problem."
Actually when we have dynamic spelling turned on it crashes if there is a different language applied.
MJP29
Copy link to clipboard
Copied
MJP29:
John's script works perfectly, but there is something wrong with opening quote in appliedLanguage="English: USA", when you copy-paste the code.
I simply retyped it.
Copy link to clipboard
Copied
Thanks Winterm and John of course. You guys are great!!
MJP29
Copy link to clipboard
Copied
winterm:
John's script works perfectly, but there is something wrong with opening quote
Indeed, both quotation marks somehow turned into the curly variety. Cut-and-paste error on my part, I am afraid. Sorry! Thanks for noticing it!
Incidently, thanks, Selva, for the paragraph style script. I had forgotten that part of the revised query (post #2). I think this should fix Selva's script:
var a = app.activeDocument.paragraphStyles;
for (var i=a.length-1; i >= 0; i--){
try {
a.appliedLanguage = app.languagesWithVendors.item("English: USA");
} catch (e) { }
}
Though I'm not sure why the middle line isn't simply
a.appliedLanguage = "English: USA";
Copy link to clipboard
Copied
John:
Works perfect and then I also used it for characterStyles.
MJP29
Copy link to clipboard
Copied
Great. And for others looking to solve this problem, I realize that it may be necessary to change "paragraphStyles" to "allParagraphStyles" if you make use of paragraph style groups. If you don't use the groups, then it should work as given.
Copy link to clipboard
Copied
MJP29:
I believe your question is answered. Don't you mind to press Correct Answer button for John? Just to keep good practice of the forum ![]()
Copy link to clipboard
Copied
Hi
Can you try this. May be it will useful to you
var a = app.activeDocument.paragraphStyles;
for (var i=a.length-1; i >= 0; i--){
a.appliedLanguage = app.languagesWithVendors.item("English: USA");
}
This will set the language whatever you want for all the paragraph styles in your document.
Thanks
Selva
Copy link to clipboard
Copied
Selva:
Your script also errors.
Error Number: 516
Error String: Invalid request on a root style.
Thanks
MJP29
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more