Jenkins : Translation Tool


Translate an application is a hard work, not only because you have to know what the software does and what the developer means with each wording, but also because normally there are not good tools to help enough.

''  is a simple but useful command-line tool to help translators of Jenkins and its plugins.

Please, take a look to Jenkins Internationalization page to understand and get a better explanation about Internationalization in Jenkins


- Jenkins uses three ways to internationalize elements:

  1. For texts used directly in .java classes, it uses '' files which contains a collection of 'key=value' lines in English. In this case you have to:
    1. Create the  file copying the original file (xx means your language code)
    2. Edit it, and replace the values for the appropriate text in your language.
  2. Jenkins uses files with the '.jelly' extension for html template files. Once you have locate these files you have to:
    1. Identify all the keys being used in the nnnnn.jelly file
    2. Create the file
    3. Add all the keys found to the new file and set the translated values.
  3. Finally there are a large amount of '.html' files used normally for help tips in the application. Find this files and:
    1. Copy the file with the name nnnnn_xx.html
    2. Edit and translate it

- Jenkins only supports files encoded with ISO-8859-1 or ASCII, so after modifying the files be sure to convert them to the correct charset.

- '' has been coded in 'perl'.

  • Perl is installed by default in any unix flavour (linux, freebsd, opensolaris, etc),
  • In Windows you have to install it (from ActiveState or Cygwin) and call the script adding the interpreter to the command line.

How helps us to translate

  • It recursively looks for translatable files in a folder, and analyzes them to extract the keys used in the application. 
  • By default (without parameters) the script writes a report to the screen with the keys which are missing, orphans, empty, or which have the same value than in English
  • Adding the parameter '--add', the script generates the appropriate files and adds missing keys to them, or updates the files if they already exist. The script put the value of the keys in English as a reference.
  • Adding the parameter '--editor=editor' the script will call the command 'editor' for each file which have untranslated keys.
  • Passing the parameter '--remove' the script will remove orphan keys which are not in use.
  • Finally the script is able to convert UTF-8 files to ISO-8859-1, or to ASCII with the java unicode representation '\uXXX' for non-ascii characteres.

Execution and Syntax

  • The tool is placed in the folder 'main' of the Jenkins trunk. So to execute it you have either to put it in your 'PATH', or add the folder before the command.
  • Execute the script without arguments to get the usage message:
    ~/home/workspace/jenkins$ main/ --help
    Translation Tool for Jenknis
    Usage: main/ --lang=xx [options] [dir]
       dir:                   -> source folder for searching files (default current)
         --lang=xx            -> language code to use (it is mandatory and it has to be different to English)
         --toiso=true|false   -> convert files in UTF-8 to ISO-8859 (default false)
         --toascii=true|false -> convert files in UTF-8 to ASCII using the native2ascii command (default false)
         --add=true|false     -> generate new files and add new keys to existing files (default false)
         --remove=true|false  -> remove unused key/value pair for existing files (default false)
         --editor=command     -> command to run over each updated file, implies add=true (default none)
         --reuse=folder       -> load a cache with keys already translated in the folder provided in
                                 order to utilize them when the same key appears
         - Look for Spanish files with incomplete keys in the 'main' folder,
           edit them with gedit, and finally convert them to ISO-8859
            main/ --lang=es --editor=gedit --toiso main
         - Convert all Japanese files in the current folder encoded with UTF-8 to ASCII
            main/ --lang=ja --toascii .
         - Remove all orphand keys from German files which are in the current file
            main/ --lang=de --remove .
  • Show a report about the status of Spanish Jenkins internationalization.
    ~/home/workspace/jenkins$ main/ --lang=es main
    File: ./maven-plugin/src/main/resources/jenkins/maven/
      Missing -> MavenModuleSetBuild.DiscoveredModule
      Empty   -> MavenModuleSet.DiplayName
      Unused  -> MavenModule.Name
      Same    -> MavenModule.Pronoun
    TOTAL: Files: 527 Keys: 1502 Done: 1498(99.73%)
           Missing: 1(0.07%) Orphan: 1(0.07%) Empty: 1(0.07%) Same: 1(0.07%)
  • And here is where the script comes really useful: I want to translate the plugin 'postbuildtask' to Spanish and the script does:
    • Generate new files with all keys to translate.
    • Translate automatically the keys which already exist in other files in the project.
    • Edit each new file using gnome text editor (gedit), so that the user can translate the keys.
    • Convert the files to ISO, after the user saves them.
      ~/home/workspace/jenkins/plugins/postbuild-task$ ../../main/ --lang=es \
         --reuse=../.. --add --remove --editor=gedit --toiso
      File: ./src/main/resources/jenkins/plugins/postbuildtask/PostbuildTask/
        Adding  -> Tasks
        Adding  -> Log\ text
        Adding  -> Delete\ task
        Adding  -> Script
        Adding  -> Operation
      Converting file ./src/main/resources/jenkins/plugins/postbuildtask/PostbuildTask/ to ISO-8859
      TOTAL: Files: 2 Keys: 5 Done: 0(0.00%)
             Missing: 5(100.00%) Orphan: 0(0.00%) Empty: 0(0.00%) Same: 0(0.00%)
  • You can use the script to edit missing keys in already translated files
     ~/home/workspace/jenkins/plugins/sonar$ ../../main/ --lang=es \
       --add --remove --editor=gedit --toiso
    File: ./src/main/resources/jenkins/plugins/sonar/
      Same    -> SonarAction.Sonar
    File: ./src/main/resources/jenkins/plugins/sonar/SonarPublisher/
      Empty   -> SonarInstallation.error
    TOTAL: Files: 6 Keys: 75 Done: 73(97.33%)
           Missing: 0(0.00%) Orphan: 0(0.00%) Empty: 1(1.33%) Same: 1(1.33%)