1 person found this helpful
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.
Thanks very much Jongware. Is there a simple way to find and change "every character that exists in a text frame" -- ie: every single possible character that might appear in a text frame, including any white space, any break character, etc. Should I be finding everything between a story's beginning and end, one or more times?
I appreciate your advice!
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.
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, doc = app.activeDocument; if (mySelection.constructor.name == "TextFrame") mySelection.texts.appliedLanguage = "English: Canadian"; else if (mySelection.hasOwnProperty ("parentTextFrames")) mySelection.parentTextFrames.texts.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 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.
Thanks again, Trevor. The script works perfectly when both paragraph and character styles are present. What about situations where only some paragraph styles are used, or no text styles applied whatsoever? Sadly, this is the situation I am facing with updating numerous existing files.
I will test your suggestions for searching all possible keystrokes to use in a FindChangeByList text file when I am back at my office.
I appreciate your additional efforts on this question!
1 person found this helpful
It sounds to me that you realy want all the documents text to be Canadian (not just a selected text frame).
var doc = app.activeDocument; doc.stories.everyItem().appliedLanguage = "English: Canadian"; doc.paragraphStyles.itemByRange(1, doc.paragraphStyles.length -1).appliedLanguage = "English: Canadian"; doc.characterStyles.itemByRange(1, doc.characterStyles.length -1).appliedLanguage = "English: Canadian";
Will set ALL text of existing stories to Canadian if you make a new story for example a new text frame which is not linked to an existing one the either make sure to set to Candian or run sript again.
Future P and C styles are likely to be set to Candian.
This is very helpful, Trevor. Your suggestion that I use (?s).* as the find what parameter was the key for me getting Jongware's Find/Change suggestion to work properly.
Thanks to you and Jongware, I now have several methods of changing text language to English Canadian based on various circumstances: when the text has paragraph and character styles applied (with the option to reformat existing styles), and also the ability to use Find/Chage to apply the change to text that is unstyled, or partially-styled.
Many thanks to you gentlemen for your kind assistance!