9 Replies Latest reply on Jul 29, 2013 4:53 PM by kvnob

    Change language in existing text

    kvnob Level 1

      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!

        • 1. Re: Change language in existing text
          Trevorׅ Adobe Community Professional

          See  here

           

          Trevor

          • 3. Re: Change language in existing text
            [Jongware] Most Valuable Participant

            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.

            1 person found this helpful
            • 4. Re: Change language in existing text
              kvnob Level 1

              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!

              • 5. Re: Change language in existing text
                kvnob Level 1

                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!

                • 6. Re: Change language in existing text
                  Trevorׅ Adobe Community Professional

                  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.

                  • 7. Re: Change language in existing text
                    kvnob Level 1

                    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!

                    • 8. Re: Change language in existing text
                      Trevorׅ Adobe Community Professional

                      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.

                      1 person found this helpful
                      • 9. Re: Change language in existing text
                        kvnob Level 1

                        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!