🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #17965

Question about repeat [AS]

#17965
From: Richard Ronnback
Date: Thu, 01 May 2003 06:49
27 lines
1851 bytes
As I don't speakt French I thought I could use the Babelfish SOAP service for rough translations. If I manually call the handler for each item in the list it works, but if try to use repeat it doesn't. Why is this? I am not very good at AppleScript, but I can't see why I get different results

To try it make an empty document with some English paragraphs (empty paragraphs will not work)

Here's the script:

 
tell application "InDesign 2.0.2" 
	set myDoc to active document 
	set myParas to object reference of paragraphs of stories of myDoc

	repeat with i in myParas 
		set this_text to text contents of i 
		tell me to set the new_text to translate("en_fr", this_text) 
		set text contents of i to new_text & return 
	end repeat

end tell

-- This handler makes the SOAP request. 
on translate(direction, theText) 
	tell application "http://services.xmethods.net:80/perl/soaplite.cgi" 
		return call soap � 
			{method name:"BabelFish", method namespace uri:"urn:xmethodsBabelFish", parameters:{translationmode:direction as string, sourcedata:theText as string} � 
				, SOAPAction:"urn:xmethodsBabelFish#BabelFish"} 
	end tell 
end translate 
Technical Details
Message-ID: <1de8f324.-1@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f939a,f58fa0f66d7887b5
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-05-01 00:07:47 PST
From: "Richard Ronnback" <richard.ronnback@telia.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Question about repeat [AS]
Message-ID: <1de8f324.-1@WebX.la2eafNXanI>
Date: Wed, 30 Apr 2003 23:49:50 -0700
Lines: 34
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit