Additional Windchill Capabilities > Service Information Management > Customizing Windchill Service Information Manager and Windchill Service Parts > Adding Custom Content or Files to a Translation Package
  
Adding Custom Content or Files to a Translation Package
This customization can be performed only by a Windchill administrator with Java expertise.
You can customize the process of creating a translation package to include additional files in a translation package. For example, metadata such as due date in a text or xml file format. Customizing the Core Translation Process workflow template enables addition of files to translation packages. The procedure to perform this customization is as follows:
1. Open the Core Translation Process workflow template in a workflow template editor.
2. Insert an expression robot after the Build Translation Package node.
3. Configure the expression of this robot node to call custom code which will modify the content of the translation package, as per your business requirements.
When you upgrade to a new version of Windchill, the customization of the workflow process template will be overwritten. You will have to apply the customization again in the upgraded system.
Following is an example of workflow code that calls the custom code to access or modify the translation package file after it has been created:
String oldUser = null;

try {
String wfCreator = com.ptc.tml.utils.TMLUtils.getUserName(main.getCreator());
oldUser = com.ptc.tml.utils.TMLUtils.switchSessionPrincipal(wfCreator);
wt.fc.Persistable sourceObj = wt.primaryBusinessObject;
wt.vc.baeline.ManagedBaseline baseline = (wt.vc.baeline.ManagedBaseline) com.ptc.tml.utils.TMLUtils.getPersistable(baselineOid);
java.io.File packageFile = new java.io.File(newTranslationPackageName);


custom.doSomething(sourceObj, baseline, packageFile);


} catch (java.lang.Throwable t) {
Log.addError(t);
} finally {
com.ptc.tml.utils.TMLUtils.switchSessionPrincipal(oldUser);
}
The session principal needs to be assigned in the workflow robot to ensure that the workflow can access any relevant Windchill objects. By default, workflow is executed as an administrator; if no Windchill objects need to be accessed then the session principal need not be changed.
Following is a sample code for iterating through the content in the translation baseline to find additional content or metadata to add to the translation package:
void doSomething(Persistable sourceObj, ManagedBaseline baseline, File packageFile) {
// open zip
for (EPMDocument doc : com.ptc.tml.utils.TranslationBaselineUtils.getBaselineDocuments(baseline))
Object extra = custom.traverse(doc);
custom.addToZip(zipFile, extra);
}
//close zip
}
It is not possible to append files to an existing translation ZIP file with standard Java APIs. To modify the translation package zip, copy the entire content of the translation package to a new zip file where the content can be altered or appended. Once the new translation package zip file is complete, the custom code can replace the original file with the new translation package file.