-
1. Re: Find text with different appliedLanguage
[Jongware] Jul 27, 2012 8:09 AM (in response to Vamitul)1 person found this helpfulA potentially destructive way, so make sure you don't accidentally save:
1. Create a new color swatch and call it 'Gut Text'.
2. Find the text with your German (2006) language applied and replace with your new swatch.
3. Search for remaining text in black.
Pro: well it's fast and should be 100% accurate.
Con: It's 'destructive' because it changes the text color. Of course you can throw away the "Gut Text" swatch and replace it with Black, but if you used any other text colors than black, it will remove these as well. Also, text in a color other than black will *not* be checked.
(You don't have to use a color swatch, you can use a couple of other text attributes. You cannot use *any* text attribute to weed out bad text -- for instance, suppose you decide to change your 'good' text to a baseline shift of 0.001pt. But then you'd have to search for "Baseline shift not 0.001pt", and InDesign cannot do that -- you'd have to search for a baseline of 0pt, and hope no-one did funny things with it.
The very best would be if you can find a pure binary text attribute -- one that is either ON or OFF -- of which you are totally sure no-one used it anywhere.)
-
2. Re: Find text with different appliedLanguage
[Jongware] Jul 27, 2012 8:14 AM (in response to [Jongware])[Jongware] wrote:
The very best would be if you can find a pure binary text attribute -- one that is either ON or OFF -- of which you are totally sure no-one used it anywhere.)
Got one: Character color, Overprint fill.
.. At least, for me that one would work O_o as I've never ever used this particular function myself.
-
3. Re: Find text with different appliedLanguage
Peter Kahrel Jul 27, 2012 8:54 AM (in response to [Jongware])1 person found this helpfulConditions are useful for this, and they leave colour alone. Plus you could leave the applied conditions in place because you see them only in preview mode.
Peter
-
4. Re: Find text with different appliedLanguage
[Jongware] Jul 27, 2012 10:13 AM (in response to Peter Kahrel)Hah -- another rare function I live to see put to good use :D
-
5. Re: Find text with different appliedLanguage
Laubender Jul 28, 2012 12:12 PM (in response to Vamitul)@Vamitul – if you know that all your text should be in a specific language, why don't you apply that language to all stories in the document?
Why do you have to report the instances of a not properly set language?The following example is not perfect (it will not get tables nested in tables), but otherwise would apply a specific language to all stories, tables (not nested! in tables) and footnotes of a given document. Do not use the string I present here for "German (2006 reform)", because its dependent of my German InDesign:
var myLanguage = /***For German InDesign, only:***/"Deutsch: Rechtschreibreform 2006"; //Perhaps use: "German (2006 reform)" //All Stories: app.documents[0].stories.everyItem().appliedLanguage = myLanguage; //All Tables: app.documents[0].stories.everyItem().tables.everyItem().cells.everyItem().texts[0].appliedLanguage = myLanguage; //All Footnotes app.documents[0].stories.everyItem().footnotes.everyItem().texts[0].appliedLanguage = myLanguage; //All Tables in Footnotes: app.documents[0].stories.everyItem().footnotes.everyItem().texts[0].tables.everyItem().cells.everyItem().texts[0].appliedLanguage = myLanguage; //CAUTION !! Not supported here: //1. Tables nested in tables
Uwe
-
6. Re: Find text with different appliedLanguage
Vamitul Jul 29, 2012 12:40 AM (in response to Laubender)@Laubender: I can't change the documents (I'm doing "loseblattwerk") and some of the pages have already been set ant printed with the errors. I only have to report them.
@ [Jongware], Peter Kahrel: Thank you for the interesting ideas. will have a look, the problem is the attribute
"of which you are totally sure no-one used it anywhere."
These documents have been through many many hands including some people that shouldn't be allowed to even touch a computer (i got in one doc 112 pages of text indented, aligned etc using the spacebar key).
-
7. Re: Find text with different appliedLanguage
Trevorׅ Jul 29, 2012 3:17 PM (in response to Vamitul)Try this.
Make a copy of your document and on the COPY run this script.
myDoc=app.documents[0]; var myLanguage = /***For German InDesign, only:***/"Deutsch: Rechtschreibreform 2006"; //Perhaps use: "German (2006 reform)" // this line stolen from Uwe uc = (app.activeDocument.conditions.item("My Unique Condition That I'm Pretty Sure Does Not Come Up In The Document (23145871834gs to be extra safe)").isValid) ? app.activeDocument.conditions.item("My Unique Condition That I'm Pretty Sure Does Not Come Up In The Document (23145871834gs to be extra safe)") : app.activeDocument.conditions.add ({name: "My Unique Condition That I'm Pretty Sure Does Not Come Up In The Document (23145871834gs to be extra safe)", indicatorColor: UIColors.YELLOW, indicatorMethod: ConditionIndicatorMethod.USE_HIGHLIGHT}); app.changeGrepPreferences = app.findGrepPreferences = null; app.findGrepPreferences.appliedLanguage= myLanguage; app.changeGrepPreferences.appliedConditions = [uc]; finds=[]; finds=myDoc.changeGrep(); uc.visible=0;
The German text will not be visible (you can make it visible by clicking on the conditional text panel)
The text you are left with is all non-German.
You might wan't to add the the find preferences; tables, footnotes, etc.
There is a professional program Language Lamp that you might like if you do this stuff a lot.
http://www.mindsteam.com/products/languagelamp/index.html
The pro version which includes scripting and preflight is http://www.mindsteam.com/products/languagelamppro/index.html
Good luck
Trevor
-
8. Re: Find text with different appliedLanguage
Trevorׅ Jul 30, 2012 8:02 AM (in response to Trevorׅ)1 person found this helpfulThe mindsteam version is a lot more proffesional (I have it) but this also makes your copy nice and pretty.
myDoc=app.documents[0]; langs=myDoc.languages; con=[]; app.changeGrepPreferences = app.findGrepPreferences = null; for (c=0;c<langs.length;c++){ app.findGrepPreferences.appliedLanguage=langs[c]; finds=new Array; finds=myDoc.findGrep(); if (finds.length>0){ r=Math.floor((Math.random()*255)); g=Math.floor((Math.random()*255)); b=Math.floor((Math.random()*255)); con[c] = (app.activeDocument.conditions.item(langs[c].name).isValid) ? app.activeDocument.conditions.item(langs[c].name) : app.activeDocument.conditions.add ({name: langs[c].name, indicatorColor: [r,g,b], indicatorMethod: ConditionIndicatorMethod.USE_HIGHLIGHT}); app.changeGrepPreferences.appliedConditions = [con[c]]; finds=myDoc.changeGrep(); } } app.changeGrepPreferences = app.findGrepPreferences = null;
One can see that the : after the UK and French are Hebrew, That would be very hard to spot without this type of script
After testing on a longer document I see the script is a bit on the slow side Oh well.
I thought it might be nice to assign a constant color scheme to the language instead of a random one so if anybodies interested change the lines after if (finds.length>0){ to this
if (finds.length>0){ cc=0 for (d=0;d<langs[c].name.length;d++) { cc+=langs[c].name.charCodeAt(d)*235; } r=cc % 255; g=(5*(13*cc-7*r)) % 255; b=(8*(9*cc-5*r-3*g) )% 255;
Message was edited by: ~ Trevor ~
-
9. Re: Find text with different appliedLanguage
Peter Kahrel Jul 30, 2012 9:11 AM (in response to Trevorׅ)1 person found this helpfulInstead of
langs=myDoc.languages
try
langs=myDoc.languages.everyItem().getElements()
which might speed things up on long documents.
Peter
-
10. Re: Find text with different appliedLanguage
Trevorׅ Jul 30, 2012 10:50 AM (in response to Peter Kahrel)Hi Peter,
I'm surprised by your answer, can't see why that should make a difference.
On testing, it does seem to make a bit of a difference but it's hard to tell.
But I found the REAL bug "
for (c=0;c<langs.length;c++){"
should become"
for (c=0;c<langs.length-1;c++){"
Quite a silly mistake
The script works really quite nicely now
(If one doesn't like the color of your favorite languages then experiment with the r g b formula)
Regards
Trevor
myDoc=app.documents[0]; langs=myDoc.languages.everyItem().getElements(); con=[]; for (c=0;c<langs.length-1;c++){ app.changeGrepPreferences = app.findGrepPreferences = null; app.findGrepPreferences.appliedLanguage=langs[c]; finds=new Array; finds=myDoc.findGrep(); if (finds.length>0){ cc=0 for (d=0;d<langs[c].name.length;d++) { cc+=langs[c].name.charCodeAt(d)*235; } r=cc % 255; g=(5*(13*cc-7*r)) % 255; b=(8*(9*cc-5*r-3*g) )% 255; con[c] = (app.activeDocument.conditions.item(langs[c].name).isValid) ? app.activeDocument.conditions.item(langs[c].name) : app.activeDocument.conditions.add ({name: langs[c].name, indicatorColor: [r,g,b], indicatorMethod: ConditionIndicatorMethod.USE_HIGHLIGHT}); app.changeGrepPreferences.appliedConditions = [con[c]]; finds=myDoc.changeGrep(); } } app.changeGrepPreferences = app.findGrepPreferences = null;
-
11. Re: Find text with different appliedLanguage
Peter Kahrel Jul 30, 2012 11:18 AM (in response to Trevorׅ)Trevor,
In your original script, every time
c < langs.length
is evaluated, the collectionmyDoc.languages
is evaluated too. When you use langs = myDoc.languages.everyItem().getElements(), you create an array and that line is not evaluated later. So the timing difference is caused by InDesign accessing its model repeatedly (your original) or not (the everyItem() route).Peter
-
12. Re: Find text with different appliedLanguage
Trevorׅ Jul 30, 2012 11:29 AM (in response to Peter Kahrel)Peter
Thanks for the explanation, very clear. Good to learn some good practices.
Trevor
-
13. Re: Find text with different appliedLanguage
Trevorׅ Jul 30, 2012 3:22 PM (in response to Trevorׅ)~ Trevor ~ wrote:
But I found the REAL bug "
for (c=0;c<langs.length;c++){"
should become"
for (c=0;c<langs.length-1;c++){"
Quite a silly mistake
The script works really quite nicely now
Oh dear, oh dear, oh dear!
Now I feel really silly, the "real" bug was not a bug and
"
for (c=0;c<langs.length;c++){"
was correct.The -1 took off English: United States (don't know what's the difference between that and English: USA, as a Brit I never looked into it.)
the -1 did make a difference, my computer was feeling moody and getting caught up with the splwow64.exe thread.
Anyway It seems to have cheered up and now come to terms with the American independence.
-
14. Re: Find text with different appliedLanguage
Vamitul Jul 30, 2012 11:34 PM (in response to Trevorׅ)Thank you all. You guys are amazing!
I had to use the slow way of doing it, checking every page and every paragraph (tabel, footnote etc. btw. i really wish there were a easyer way of getting EVERY text in a textframe), since the script has to check for quite a few more types of errors. Next I will try to remake the entire script as a extension using Flex (i think it's about time i start learning it).
However, tervor's script will be very usefull for a few other projects.
Now, few questions for peter:
1) can you tell me a bit more about what getelements() does? Adobe's documentation is very vague about it.
2) i think i remember a "go to line" script created by you, but i can't find it. i figured that since my script already creates a report of all the problems in the document, might as well give the user the option to jump directly to the problem afterword.
Thank you again all!
ps. does anyone else have problems with the forum login?
-
15. Re: Find text with different appliedLanguage
Laubender Jul 31, 2012 1:54 AM (in response to Vamitul)@Vamitul – about "everyItem().getElements()" there are two blog posts by Marc Autret at www.indiscripts.com:
http://www.indiscripts.com/post/2010/06/on-everyitem-part-1
http://www.indiscripts.com/post/2010/07/on-everyitem-part-2
Uwe
Message was edited by: Laubender
-
16. Re: Find text with different appliedLanguage
Peter Kahrel Jul 31, 2012 2:28 AM (in response to Vamitul)> but i can't find it
That script isn't useful for your purposes (but it's here: http://www.kahrel.plus.com/indesign/goto_line.jsx just in case you want to convince yourself). All you need is a page number and/or a line number on that page. In CS5 and later, getting page numbers of found items is easy. Line numbers are messier:
myFinds = myDoc.findGrep();
for (i = 0; i < myFinds.length; i++)
{
$.write ('Found ' myFinds[i].contents + ' on page ' + myFinds[i].parentTextFrames[0].parentPage.name);
$.writeln ('at line ' + myFinds[i].parentTextFrames[0].insertionPoints.itemByRange(0, myFinds[i].index).lines.length);
}
This can be formulated more efficiently, no doubt, but you get the picture. Naturally, this makes sense only in one-frame pages such as novels -- footnotes and tables aren't catered for.
Peter
-
17. Re: Find text with different appliedLanguage
Pickory Aug 2, 2012 10:02 AM (in response to Peter Kahrel)