There is an OTB workflow that does this already. A custom process can be implemented that initiates a translation package as follows.
org.apache.logging.log4j.Logger logger = org.apache.logging.log4j.LogManager.getLogger("com.ptc.tml.workflow.CoreWorkflow");
logger.trace("Build Translation Package - entered");
String oldUser = null;
wt.inf.container.WTContainer container = null;
String targetLang = "";
com.ptc.tml.collection.TranslationCollection collection = com.ptc.tml.collection.TranslationCollection.fromOidString(collectionOid);
try {
wt.workflow.engine.WfProcess main = (wt.workflow.engine.WfProcess)self.getObject();
final String wfCreator = com.ptc.tml.utils.TMLUtils.getUserName(main.getCreator());
oldUser = com.ptc.tml.utils.TMLUtils.switchSessionPrincipal(wfCreator);
userName = collection.getUserName();
outputDir = collection.getOutputDirectory();
container = collection.getContainer();
targetLang = collection.getTargetLanguage();
containerOid = collection.getContainerRef().getKey().toString();
final String sourceLang = collection.getSourceLanguage();
wt.vc.baseline.ManagedBaseline baseline = com.ptc.tml.utils.WorkflowAdapter.createBaseline(collection, log);
if (baseline == null) {
baselineOid = null;
log.addErrorNoDocsToTranslate();
logger.trace("Collection " + collection.getName() + ": " + errorMsg);
} else {
log = new com.ptc.tml.log.TmlPackageLog(baseline, collection.getSourceLanguage(), targetLang, log);
baselineOid = com.ptc.tml.utils.TMLUtils.getReference(baseline);
logger.trace("Collection " + collection.getName() + " -> Baseline " + baselineOid);
newTranslationPackageName = com.ptc.tml.utils.WorkflowAdapter.
createTranslationPackage(baseline, collection.getSourceOid(), sourceLang, targetLang, userName, outputDir, container, log).getAbsolutePath();
if (log.numErrors() == 0) {
//Store notification messages
successMessage = new StringBuilder(log.toHtmlSummaryString());
warningMessage = new StringBuilder(log.toHtmlWarningString());
}
logger.trace("Baseline " + baselineOid + " -> Package " + newTranslationPackageName);
}
} catch(java.lang.Throwable t) {
log.addError("Build Translation Package", t);
} finally {
if (log.numErrors() > 0) {
log.writeErrorLog();
errorMsg = log.toHtmlSummaryString();
}
com.ptc.tml.utils.TMLUtils.switchSessionPrincipal(oldUser);
}
logger.trace("Build Translation Package - exiting");