Custom Translations

This article explains how to add and configure custom translations to the Activiti task management in the CMS. These custom translations can be used to render translated messages for form fields in custom processes.

1 Configure Custom Translations

When creating a custom process there may be the need for a form which is displayed to the user automatically by the task management app. In an activiti process a form is usually configured like this:

MyProcess.bpmn20.xml

<extensionElements>
	<activiti:formProperty id="numberOfDays" name="Number of Days" type="long"/>
	<activiti:formProperty id="firstName" name="First Name" type="string" />
	<activiti:formProperty id="lastName" name="Last Name" type="string" />
</extensionElements>

The description of each form element is displayed to the user (per default untranslated). To display the text translated you can configure custom resource bundles. These bundles need to be deployed with the custom process and need to be available in the task management app’s classpath in the java package “com.gentics.contentnode.activiti.i18n.custom”.

To include translations for German and English two files are needed in the package:

  • MyCustomBundleName.properties (which holds the English translations)
  • MyCustomBundleName_de.properties (which holds the German translations)
MyCustomBundleName.properties

myprocess.number-of-days=Number of Days
myprocess.firstname=First name
myprocess.lastname=Last name
MyCustomBundleName_de.properties

myprocess.number-of-days=Anzahl an Tagen
myprocess.firstname=Vorname
myprocess.lastname=Nachname

The task management app needs to be configured to use the bundles

gentics-activiti.properties

# Configure a list of custom translations (Java ResourceBundle names)
i18n.resource-bundles.custom=MyCustomBundleName,AnotherCustomBundle

and in the process definition the keys of the translations must be used instead of the textual description

MyProcess.bpmn20.xml

<extensionElements>
	<activiti:formProperty id="numberOfDays" name="myprocess.number-of-days" type="long"/>
	<activiti:formProperty id="firstName" name="myprocess.firstname" type="string" />
	<activiti:formProperty id="lastName" name="myprocess.lastname" type="string" />
</extensionElements>

All ResourceBundles are loaded in the order they are configured. If two bundles contain the same key the translation of the last configured bundle will be used.

2 Overriding Core Translations

Overriding core translations is not part of the official API since translation keys can change without notice between releases! Use at your own risk!

Create a ResourceBundle with custom translations for the core place it in the java package “com.gentics.contentnode.activiti.i18n.core” and deploy it with the task management app.

gentics-activiti.properties

# Configure a list of core translations
# Messages-Core is the default ResourceBundle for translations
i18n.resource-bundles.core=Messages-Core,OverrideMessagesCore