Skip to main content
Participant
July 25, 2013
Answered

Change language in existing text

  • July 25, 2013
  • 1 reply
  • 1762 views

I'd like to find a script that can find all text in a document that doesn't use the character language "English: Canadian" and change it to use "English: Canadian". I hope to add this script to an existing FindChangeByList text file.

Thanks in advance for any assistance with this!

This topic has been closed for replies.
Correct answer Trevor:

Hi Trevor, Thanks for the assistance. I'll use this script if I cannot find a way to make the changes via a FindChangeByList script.

Much appreciated!


Hi kvnob,

Jongware is definatly correct that you don't nead to loop through the languages in your case.

To set all text in a text box to Candian you could use:

var mySelection = app.selection[0],

       doc = app.activeDocument;

if (mySelection.constructor.name == "TextFrame") mySelection.texts[0].appliedLanguage = "English: Canadian";

else if (mySelection.hasOwnProperty ("parentTextFrames")) mySelection.parentTextFrames[0].texts[0].appliedLanguage = "English: Canadian";

// To set all character / paragraphs styles to Canadian

doc.paragraphStyles.itemByRange(1, doc.paragraphStyles.length -1).appliedLanguage = "English: Canadian";

doc.characterStyles.itemByRange(1, doc.characterStyles.length -1).appliedLanguage = "English: Canadian";

to do the whole document just change app.selection[0] to app.activeDocument

But you can do the same with the find change dialog as stated.

It is normaly quite easy to find a common denominator to search for that will include everything including white spaces of all types (which by the way are considered black if that's the set text color) try setting under the find format the strikethough gap color to none.

Alternatively you could leave the find format alone and use find grep puting (?s).* in the find what box.

1 reply

Trevor:
Legend
July 25, 2013

See  here

Trevor

Trevor:
Legend
July 25, 2013
Jongware
Community Expert
Community Expert
July 26, 2013

No need to try and loop for 'all languages except Canadian', as all text should be set to "English:Canadian". Simply pick any attribute that is the same for all of the text in your document (all black? all in the font Arial? all with 0 Drop Characters?) and "change" it to your language. That can be done with FindChangeByList.