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

Script to Change Language to English: USA

Guest
Nov 23, 2011 Nov 23, 2011

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

TOPICS
Scripting
5.8K
Translate
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

correct answers 1 Correct answer

LEGEND , Nov 29, 2011 Nov 29, 2011

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.

Translate
LEGEND ,
Nov 23, 2011 Nov 23, 2011

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.

Translate
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
Guest
Nov 28, 2011 Nov 28, 2011

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

Translate
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
LEGEND ,
Nov 28, 2011 Nov 28, 2011

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”;

Translate
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
Guest
Nov 29, 2011 Nov 29, 2011

John:

Your last script does not work. Getting an error.

Error Number: 8

Error String: Syntax error

MJP29

Translate
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
Guest
Nov 29, 2011 Nov 29, 2011

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

Translate
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
Mentor ,
Nov 29, 2011 Nov 29, 2011

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.

Translate
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
Guest
Nov 29, 2011 Nov 29, 2011

Thanks Winterm and John of course. You guys are great!!

MJP29

Translate
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
LEGEND ,
Nov 29, 2011 Nov 29, 2011

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";

Translate
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
Guest
Nov 29, 2011 Nov 29, 2011

John:

Works perfect and then I also used it for characterStyles.

MJP29

Translate
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
LEGEND ,
Nov 29, 2011 Nov 29, 2011

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.

Translate
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
Mentor ,
Nov 30, 2011 Nov 30, 2011
LATEST

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

Translate
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
Explorer ,
Nov 29, 2011 Nov 29, 2011

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

Translate
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
Guest
Nov 29, 2011 Nov 29, 2011

Selva:

Your script also errors.

Error Number: 516

Error String: Invalid request on a root style.

Thanks

MJP29

Translate
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