Copy link to clipboard
Copied
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.
Questions:
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)?
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 be
...Copy link to clipboard
Copied
That can be accomplished with Data Sets.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
you're welcome, just do a quick test with 2 or 3 text Frames, save the xml file, edit it yourself and import it back to illustrator to see how it works. Post back if you need help.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
This was my thoughts… on your situation… With what you have to do I saw little or no advantage to using XML… unless you have an automated way in which to generate it (directly from Excel perhaps?). I've never done this… I've tried several times but Illustrator is very particular over the XML formating and I've never resolved the issue. If this were my job to do then I would write the required info out to text file. For use in Excel or FMP, add the translations then save back out to text for reading back into the files. I don't do VB but may have 'some' time to look at this in JavaScript which will work on either platform…
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
oh sorry, the sample doesn't check for errors, it assumes there's an open Excel book and an open Illustrator Document with some text in it.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
- repeat
wow...that looks like a bigger project
Copy link to clipboard
Copied
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
in 2d
Copy link to clipboard
Copied
you're welcome
Copy link to clipboard
Copied
Hello,
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.
Region 1:
en-US
text 1
text 2
fr-FR
text 1
text 2
de-DE
etc...
Region 2:
en-US
text 3
text 4
ru-RU
text 3
text 4
Region 3:
etc..
I hope someone will be able to give me some help,
François
Copy link to clipboard
Copied
I use a tool called Sysfilter for Illustrator for conversions to XML and translation... This should also work.
Copy link to clipboard
Copied
Hi Guillermo, is it possible to include the original illustrator file in the target translator file so that the translator can also see the effect of their translation on the interface to immediately learn if it fits into the text area and the layout of the translation.