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.
'translation-tool.pl' 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:
- For texts used directly in .java classes, it uses 'Message.properties' files which contains a collection of 'key=value' lines in English. In this case you have to:
- Create the file Message_xx.properties copying the original file (xx means your language code)
- Edit it, and replace the values for the appropriate text in your language.
- Jenkins uses files with the '.jelly' extension for html template files. Once you have locate these files you have to:
- Identify all the keys being used in the nnnnn.jelly file
- Create the file nnnnn_xx.properties
- Add all the keys found to the new file and set the translated values.
- Finally there are a large amount of '.html' files used normally for help tips in the application. Find this files and:
- Copy the file with the name nnnnn_xx.html
- 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.
- 'translation-tool.pl' 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 translation-tool.pl 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:
- Show a report about the status of Spanish Jenkins internationalization.
- 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.
- You can use the script to edit missing keys in already translated files