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
Use the following steps to propagate the changes to translation.service.properties.xconf.
1. Create a custom xonf file at <customizationRootDirectory> that contains the appropriate new value for the property:
<Service context="default"
name="com.ptc.tml.validation.PrePopulateTargetLanguagesHook">
<Option requestor="java.lang.Object"
serviceClass="com.ptc.tml.sample.YourSamplePrePopulateTargetLanguagesHookImplClassName"
selector="null"/>
</Service>
2. Organize and deploy the changes using CCD. For more information, see Setting Property Values and Propagating Your Changes. For information on creating a modular file structure for Windchill+, see the example: Installing or Enabling Configurable Links with New Custom Subtyped Configurable Links Example.
Isto foi útil?