Here I posted some links for first-time scripters. From my own experience (I'm not a programmer by background), I can tell you that EVERYBODY can write scripts — the devil is not so terrible as he is painted!
The most difficult is to make the first step. But when you make progress in it, another problem appears: you can't stop — scripting is very absorbing.
On this site, I find a lot of information on how to use InDesign — both for beginners and advanced users. There are many "ready to use" scripts here as well. But I've never seen a scripting tutorial here and remember reading only one scripting trick lately.
I think this is a big omission for indesignsecrets and suggest that a series of scripting lessons, tutorials, articles, tips & tricks, etc. should be started here on regular basis.
Kasyan, I think you have a great idea. We will certainly think about how we can include some beginner scripting articles here, trying not to scare away designers and other users.
Sure, no problem. May Be Handy: if you have some text selected, it will be the initial language in the Find box.
Main();
function Main() {
if (app.documents.length == 0) {
alert("Please open a document and try again.");
exit();
}
langList = app.languagesWithVendors.everyItem().name.sort();
langList.splice (0,0, langList[langList.length-1]);
langList.pop();
preselected = 0;
if (app.selection.length == 1 && app.selection[0].hasOwnProperty("appliedLanguage"))
{
for (i=0; i<langList.length; i++)
{
if (langList[i] == app.selection[0].appliedLanguage.name)
{
preselected = i;
break;
}
}
}
The convulated stuff right after retrieving the language list is because the languages don't come in their usual sorted order. It's easy to apply a sort, but then [No Language] ends up at the bottom. Rather than writing a custom sort function, I merely move the last item up to the top. I'm only assuming that'll actually always be [No Language].
I don't mean to look a gift horse in the mouth, but this very handy script seems not to work for languages that don't come with ID, such as Chinese and Japanese (it took me a while to realize my ID grabbed those languages from imported files). Poking around, I found an older script Jongware made available over on Adobe's ID scripting forum that does find all the languages in a document, though so thorough a check takes time. I often get files with all kinds of odd languages, and I can't search for them unless I know they're there. So I really want to thank Jongware for both scripts.
Well, David, you are correct in your observation of the behavior of these two scripts. The one above inquires InDesign about the list of supported languages, and the one you mention reads them from a document — which, annoyingly, may include text in a language that's actually not supported! So you can't use this script to remove the non-supported languages.
Oh, the conundrum.
I'll take a peek to see if it's possible to combine the two (and make the list of not-supported languages appear in a section of their own, in full ID Font List style. Also, if possible.)
How exactly do I install this script in ID (I have CS4 and CS5.5 (Mac OS 10.6.8)? And is it Java or AppleScript? I found this explanation of how to install a script (http://indesignsecrets.com/how…..design.php), but since what Jongware provided is the text of the script and not a script file, I don't know what to save it as (.js, .jsx, .as, .scpt).
I went to Apple Script Editor and tried to save it as .scpt, since that's what came up. I got a syntax error: "Unknown token can't go after this ")". It was referring to the ); at the end of Main();. So I'm assuming this was a Java script. Next I went to TextEdit and pasted in Jongware's script saving it as Language_Change_Throughout.jsx. I put it in the Scripts Panel folder, and it now shows up in ID CS5.5. And it works beautifully! Thank you, Jongware!
I am posting this simply for other newbies who might not know how to install the script text above.
Eric, sorry — you are correct, I re-read my post and indeed forgot to mention it's Javascript.
InDesign supports three different scripting languages out-of-the-box, and so it would be wise to always state what language is used There are a few small clues, though, hidden inthe "syntax":
AppleScript uses a syntax based on English:
tell application "InDesign" to copy item 3 of page 1 … — this is a comment
etc. (I'm making this one up as I don't speak AppleScript).
Visual Basic leans heavily on ye olde Basic and has Initial Caps for Everything:
Sub CopyItem (item) ' a comment after a ' sign
x = Rectangles.Add()
Javascript looks like … the above Lots of curly braces, a semicolon to end each command.