Copy link to clipboard
Copied
I am attempting to write a script which completes a series of auto-transalation for series of flyer we convert to bilingual. I am very new to javascripting. I am have having uses understanding how appliedConditions is used/coded to work.
- This what I drafted up. (Both the Character style and Condition are already in the document created either thrua script or the styleif copy tot eh document.)
- I am using GrepPreferences vs TextPreferences because later on I have GREP searches to complete.
app.findChangeGrepOptions = null;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = '(?i)Assorted SKUs';
app.changeGrepPreferences.appliedCharacterStyle = 'Pigiarniq - Bold';
app.changeGrepPreferences.changeTo = 'ᐊᔾᔨᒌᙱᑦᑐᓂ ᓈᓴᐅᑎᓖᑦ';
app.changeGrepPreference.appliedConditions = ['DoNotTranslate'];
app.activeDocument.changeGrep();
I get error number 55
thank you in advance
Copy link to clipboard
Copied
You have a slight typo in your code, you have a missing s. Use the following
app.changeGrepPreferences.appliedConditions = ['DoNotTranslate'];
In the document you should have a condition DoNotTranslate present, then i don't get any errors.
-Manan
Copy link to clipboard
Copied
Manan,
thank you - clearly end of day on friday not the best time for my dyslexic brain - thank you so very much 🙂
JJ
Copy link to clipboard
Copied
Follow up
I now need to apply just the condition to text without the replacing of the text and it not working
function grep_reset(){
app.findGrepPreferences = NothingEnum.nothing;
app.findChangeGrepOptions.includeLockedLayersForFind = true;
app.findChangeGrepOptions.includeLockedStoriesForFind = true;
app.findChangeGrepOptions.includeHiddenLayers = false;
app.findChangeGrepOptions.includeMasterPages = true;
app.findChangeGrepOptions.includeFootnotes = true;
app.changeGrepPreferences = NothingEnum.nothing;
}
app.findGrepPreferences.findWhat = '\$\d\d*,*\d+\.\d\d';
app.changeGrepPreferences.appliedConditions = ['DoNotTranslate'];
app.activeDocument.changeGrep();
grep_reset();
can you enlighten me as to what I goofed up this time?
Copy link to clipboard
Copied
On first look it seems a problem with escaping the grep string. Use the following it should work
app.findGrepPreferences.findWhat = '\\$\\d\\d*,*\\d+\\.\\d\\d';
-Manan
Copy link to clipboard
Copied
Hi JJ_Cloutier,
if you want to test an expression like:
app.findGrepPreferences.findWhat =
Simply execute the command and then switch to InDesign's GREP Find/Change panel to see what exactly happened.
This one executed:
app.findGrepPreferences.findWhat = '\$\d\d*,*\d+\.\d\d';
will yield this result:
This is an easy way to debug your GREP Find expressions.
Regards,
Uwe Laubender
( ACP )