Google Translator - User Exit, used in Translation Map

Mirjana's picture
Creating User Exit for Google Translator
Steps to do:
  • Download java api (package) for google translation
  • Install google translation package in SI system
  • Write user exit code
  • Compile and pack user exit code
  • Install user exit in SI system
  • Write the map that will use the user exit
1. Download google-api-translate-java-0.92.jar or newer that can be found at
Note: Be careful with google translator API version and java version used by SI. I think for GIS/SI versions that uses java 1.5 we should use Google Translator 0.92 and SI system that uses java 1.6, we should take Google Translator 0.95!
2. Install the jar with script in SI system
SI_Install_Folder/bin/install3rdParty.cmd GoogleTranslator 0_92 -j /path_To_Jar/google-api-translate-java-0.92.jar
You will be able to find the jar file in
  • SI_Install_Folder/jar/GoogleTranslator/0_92/
  • Also, you will see the following line in the end of dynamicclasspath.cfg file:
3. Java code for user exit (
package google.translation;
         public class GoogleTranslation {
                   public String trans(String str, String sourceLanguage, String targetLanguage) {
                            String translatedText = new String();
                            try {
                                      translatedText = Translate.execute(str, Language.valueOf(sourceLanguage), Language.valueOf(targetLanguage));
                                      } catch (Exception ex) {
                                      return translatedText;
4. Compile into GoogleTranslation.class
Compilation can be done with a proper version of java in eclipse or in the command line.
SI_Install_Folder/jdk/bin/javac /path_To_Java_Code/
… or …
C:\temp>c:\SterlingCommerce\MEFG_43\jdk\bin\javac -classpath c:\temp\google-api-translate-java-0.92.jar
GoogleTranslation.class should be created in the folder in which you have run the command.
5. Pack the class file into jar
  • Place the class file under package folder (google/translation)
  • Change directory to parent folder of ‘google’
  • SI_Install_Folder/install/jdk/bin/jar cvf GoogleTranslation.jar google
GoogleTranslation.class, in package (jar), must be under google\translation path, that means in the package defined in code.
6. Install GoogleTranslation.jar at SI system
SI_Install_Folder/bin/install3rdParty.cmd UserExit 1_0 -j /path_To_Jar/GoogleTranslation.jar
After installing google translate api (google-api-translate-java-0.92.jar) and GoogleTranslator.jar package as a User Exit, you can also find the following lines in dynamicclasspath.cfg (SI_Install_Folder/properties folder):
  • Restart GIS/SI system!!!
7. Google translation in Translation map
  • Extended rule in a #field:
object obj;
String[50] sourceLanguage;
String[50] targetLanguage;
obj = new("google.translation.GoogleTranslation");
sourceLanguage = "ENGLISH";
targetLanguage = "CROATIAN";
#word = obj.trans(#word,sourceLanguage,targetLanguage);
  • Input file:
Welcome to the World of Integration.
Wish you a nice day!
Different results for translation to CROATIAN, SPANISH and GERMAN languages:
  • Result of translation (from ENGLISH to CROATIAN langugae):

Dobro došli u svijet integracije.                                                                   
Želimo vam lijep dan!
(For specific Croatian characters I added 0x00 – 0xFF range in X Syntax Token and also set Encodings at both sides of the map to Cp1250 - Windows Eastern European)
  • Result of translation (from ENGLISH to SPANISH language):
sourceLanguage = "ENGLISH";
targetLanguage = "SPANISH";
Bienvenido al mundo de la integración.                                                             
Deseamos un buen día!                                                                              
  • Result of translation (from ENGLISH to GERMAN language):
sourceLanguage = "ENGLISH";
targetLanguage = "GERMAN";
Willkommen in der Welt von Integration.                                                            
Wünsche dir einen schönen Tag!                                                                     
8. Uninstall/Remove User Exit
  • Remove GoogleTranslation.jar from SI_Install_Folder/jar/User Exit/1_0, or remove the whole UserExit folder if there is nothing you need from it any more
  • Remove google-api-translate-java-0.92.jar SI_Install_Folder/jar/GoogleTranslator/0_92 or remove the whole GoogleTranslator folder if you do not need it any more
  • Remove the lines from dynamicclasspath.cfg file that reference to these packages, mentioned in the previous steps