Custom Hook to Pre-populate Target Languages for Translation
The PrePopulateTargetLanguagesHook is used to pre-populate a list of target languages in the Create Translation Package dialog box.
The set of languages that is returned from the hook must be legal for the root object of the Translation Package.
For example, if a language is returned but the user does not have a role in the library for that language, the language appears as strikethrough under the Available Target Languages list and is not pre-populated in the Selected Target Languages list.
Or, if the target language is not valid or is not in the Supported Languages preference, the invalid target language is not pre- populated in the Selected Target Languages list. An error message for the invalid language is displayed in the method server.
The combination of available and selected target languages populated in the Create Translation Package can be manually shuffled to meet the translation requirement.
The implementation of this hook requires you to specify the name of the hook in the PrePopulateTargetLanguagesHook property.
Interface
package com.ptc.tml.validation;

import java.util.Set;

import wt.fc.Persistable;
import wt.util.WTException;

/**
* This interface provides a way to preselect the target languages to be displayed under
* 'Selected Target Languages' section in Create translation package dialog.
*
* <BR>
* <BR>
* <B>Supported API: </B>true <BR>
* <BR>
* <B>Extendable: </B>false
*/
public interface PrePopulateTargetLanguagesHook {

public Set<String> getSelectedTargetLanguageCodes(Persistable p) throws WTException;
}
See also, SamplePrePopulateTargetLanguagesHookImpl.java which is a sample implementation that has been provided for reference.
/**

* Sample implementation for the {@link PrePopulateTargetLanguagesHook}.

* There are 3 valid language codes 'ar', 'bg' and 'cs' mentioned and one language code 'pg' is invalid code.

*/

public class SamplePrePopulateTargetLanguagesHookImpl implements PrePopulateTargetLanguagesHook{



@Override

public Set<String> getSelectedTargetLanguageCodes(Persistable p) {

Set<String> result = new HashSet<>();

result.add("ar");

result.add("bg");

result.add("cs");

result.add("pg");

return result;

}

}

Registry
1. Use the xconfmanager utility to edit translation.service.properties.xconf. You can also register it in the components.service.properties file located at <Windchill>/codebase/com/ptc/core/components.
For information on using the xconfmanager utility, see About the xconfmanager Utility.
2. Add the following property:
<Service context="default"
name="com.ptc.tml.validation.PrePopulateTargetLanguagesHook">
<Option requestor="java.lang.Object"
serviceClass="com.ptc.tml.sample.YourSamplePrePopulateTargetLanguagesHookImplClassName"
selector="null"/>
</Service>
3. Save the file.
4. Propagate your changes using the xconfmanager utility. From the <Windchill>\bin directory, enter the following command:
xconfmanager -pF
5. Restart the method server.
Was this helpful?