I am trying to find a way to expedite translations of our drawings. Each drawing has a series of callouts showing what that piece of the drawing is via text. I would need to do 100's of drawings for each book.
1. Can I write something to batch a folder and extract the name of the file, and the text from each textbox so that when I get the translation back, I can automate the reinsertion of the translated text to its correct field (i.e. TextField1 = "Translate this" then repopulate that same exact field with "Translation")? In order to do this I would think each text field would have to be tagged with some unique identifier so that it would know which translation goes where in the drawing. Keep in mind, I'm ok with manually tagging each textbox if necessary.
2. Assuming the above is possible, what would be the best program to write the extracted text to so that reading and writing the translated text back into the drawing is as easy as possible (i.e. Word, Excel, PDF)?
Thanks a lot, can this be used as a method to populate the text without
scripting? For instance, will this variable set be able to be sent to the
translators and they translate it, then reload the data for that drawing?
Mind you there would be 100's of drawings at a time.
scripting is not necessary, but it could be used, let's say your art has a 100 pices of text all in English, you select one at a time and make it dynamic (make variable1, variable2...variable100). Once you have all your variables, you capture a Data Set, export that data set (an xml file, like BilingualText.xml), then modifie the xml to include your translated text and import back to Illustrator. Now you will be abel to switch between English and the translation.
or if you don't need to switch between languages, just export the file as something like English.xml, then have it translated and saved as Spanish.xml for example and load the file each time its needed.
Thank you very much for your speedy response, you may have saved me hours of
redundant copy+pasting. So I'll forward the xml file in some sort or
viewable format for them to do their translations than paste that back into
the xml file and load it. At least I think from what you're telling me, I
can do just that.
Well I wish I could give you some points, post something on my question and
I'll give you the rep credit!
Edit: I was answering this via email, didn't realize it was actually being posted! Gave you credit
Quick thing I thought of, will I have to send out an XML file for each of 100 files or is there a smart way to concatenate them in and out of a single file to reduce clutter and confusion?
Sent from my iPhone
That XML just spits out too much information. Thanks for the potential
solution, but I'd be right back to square one, only extracting the text from
the XML file instead of the illy file. I think I can run a script that will
step through all the text fields and assign them variable names, list the
drawing number, variable name, and the text within that field, and write it
all to a spreadsheet.
Yea Mark, I have laid out the skeleton of the script I need to write, I just have to find a way to step through all the text fields in the drawing via code and assign them a variable. OR utilize an already unique identifier for each text field that I can access via code, that way the identifier can be coupled into the spreadsheet. I need to use a spreadsheet because it needs to have the drawing/filename, each text variable, then the text in that corresponding text field. So something similar to this relational example: Drawingname.Textfield1.text = "English", I need that info organized like this so I can automate the input of the translated text to the correct text fields on the correct drawings/Ai files.
So all in all, I will batch a folder of drawings and the script will access the activedocument, do a For/Next loop to either gain the unique identifier or change each to dynamic text and assign each a name Text(i), then in the loop it will write to a single column, FilenameText(i), then in the next column write the text in that field "English", save, close, next drawing. Done, send it off to the translators in excel format because that's what they use to feed their software.
The ReWrite script would read the currently batched ActiveDoc, then find that filename in the spreadsheet, and step through each text variable, replacing the english with the new foreign translation. All that's left to do is watch the batch run so I can catch anything that makes the text so long from being in another language, that it overlaps another text field.
too bad Data Sets didn't work for your project.
back to square one, scripting sample using VBA
Sub translate() Dim iapp As New Illustrator.Application Dim idoc As Illustrator.Document Dim tFrame As Illustrator.TextFrame rou = 1 colum = 3 'read 'colum = 4 'write Set idoc = iapp.ActiveDocument For Each tFrame In idoc.TextFrames Cells(rou, colum) = tFrame.Contents 'read 'tFrame.Contents = Cells(rou, colum) 'write rou = rou + 1 Next Set fFrame = Nothing Set idoc = Nothing Set iapp = Nothing End Sub
text frames contents are read into column C, translation into column D
then back to Illustrator
Above and beyond sir, I can't thank you enough. I understand all of the
code, I see that the comment marks are reversed when putting things back
into Ai. The only thing I don't understand is how you wrote to a
spreadsheet without opening an instance of excel in the code.
I can code it to open a spreadsheet and save it automatically, but I don't see anything in place to make sure the write function puts the translated text in the exact box the english came from, no sort of naming convention to check that it doesn't mix them up. I assume illustrator is going to read the textfields in the same order as it did when I wrote the spreadsheet? And I'll be writing 100s of drawings to one Excel file. And they'll have to all be distinguishable from one another. What I was thinking of doing is copying the filename in column1 and a text number in column 2 the english and translation in Col3 and 4.
So last dilemma is, do I have the script search my spreadsheet for the active filename then pull from that row, or assume the batch will go in the exact same order it did the first run through, which is back to front I think.
no need for text IDs, the code will loop thru the text fields from top to bottom in the stacking order (see the layer screen shot).
if you plan to do 1 excel file againg 100s of Illustrator files, it gets a little more complicated
- loop thru all illustrator files in a folder, open one at the time and
- get name
- write name in column A
- loop thru all text, write in column B
- close file when done
- open next file, repeat
I would then write a separate procedure for writing back to illustrator
- read file name from column A
- open file
- loop thru all text, in column C
- write back to illustrator
- check for file name in column A
- repeat while column A is still the opened IL file
- when column A finds a new file
- close file
- open next file
wow...that looks like a bigger project
Well much of it I can do through Ai actions. For instance the closing and
saving. So it can just run the script as a component of an action, upon
opening the file in a batch process, then at the end of the action, save
over itself (as I'll be copying them all to a separate translation folder),
then close, open next one. I appreciate you helping me through the process
of getting it done and some code snippets, you may have helped save me hours
upon hours of work some weeks. Which means I can work more in 3d and less
We have more and less the same issue here while it's a bit more complex as we have several languages on the same packaging. Moreover, we have different text sources that would require to be translated in different sets of languages.
I have already looked in the data set and I tried to get familiar with it. I'm just wondering if someone has a good idea on how to create the data set knowing that there are different source texts for a particular region (region means a set of languages) and other texts for another region... The idea is to export this into one XML file with well identified elements that can be split with a tool, sent for translation according to their region then merged back into one single file.
I hope someone will be able to give me some help,
Europe, Middle East and Africa