Customizing Translation Creation Hook
Use the translation creation hook to customize the general attributes of translation objects created for a translation package. The translation creation hook is controlled by the xconf property com.ptc.tml.preparation.CustomTranslationCreationHook in the wt.properties file.
The steps to customize the translation creation hook are as follows:
1. Develop java code — Create a java class that extends the abstract class com.ptc.tml.preparation.CustomTranslationCreationHook and implements the desired behavior per your business requirement.
2. Register the customization — Create a custom xconf file at location <customizationRootDirectory>/configurations/xconf/ custom.site.xconf that contains the appropiate value of the property:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configuration
SYSTEM "xconf.dtd">
<Configuration xmlns:xlink="http://www.w3.org/1999/xlink">
<Property name="com.ptc.tml.preparation.CustomTranslationCreationHook"
overridable="true"
targetFile="codebase/wt.properties"
value=<"className>"/>
</Configuration>
The value of the property should be the name of the class implemented in step 1.
3. Organize and deploy the changes using CCD. For more information, see Setting Property Values and Propagating Your Changes.
* 
It is not recommended to modify the CADNAME of a translation document.
Following is a sample code which adds the prefix ‘PTC’ to the Translation Number attribute of translation documents.
package com.ptc.tml.preparation.sample;

import java.util.List;

import wt.util.WTException;
import wt.util.WTPropertyVetoException;

import com.ptc.tml.preparation.CustomTranslationCreationHook;

/** Example implementation of CustomTranslationCreationHook that customizes translation objects by prepending "PTC"
* to each translation object's Number. This is enabled by adding
* 'com.ptc.tml.preparation.CustomTranslationCreationHook=com.ptc.tml.preparation.sample.PrefixCustomTranslationObjectCreationHook'
* to wt.properties. */
public class PrefixCustomTranslationObjectCreationHook extends CustomTranslationCreationHook {

@Override
protected void customize(List<EPMDocumentCopyInfo> documentCopies) throws WTException, WTPropertyVetoException {

for (EPMDocumentCopyInfo info : documentCopies) {
final String initialNumber = info.getTarget().getNumber();
info.getTarget().setNumber("PTC" + initialNumber);
}
}
}
Was this helpful?