Tasklist: localize taskname

339 views
Skip to first unread message

Karl-Heinz Stöckler

unread,
May 8, 2015, 4:04:36 AM5/8/15
to camunda-...@googlegroups.com, karl-hein...@gmx.at

Hi,

can somebody help me to localize the tasknames in the tasklist?

I am trying to localize my tasklist. What I already found out is how to localize the labels and buttons of the tasklist.

I also know already how to localize the labels of my forms. I add key value pairs to the different json files (en.json, de.json).

The only thing which I do not know is how to localize the names of the task. Now the Name which is defined in the name attribute of the user task is shown.
example:

    <bpmn2:userTask id="UserTask_4" camunda:assignee="${initiator}" camunda:formKey="embedded:app:forms/chooseOption.html" name="Choose Option test">

and in the tasklist it looks the following way: [1]

Can I somehow localize this name by adding key Value Pairs to the *.json files?

Thank you!
Karl


[1] https://lh3.googleusercontent.com/-BCDdwqANnIU/VUxtz9X22vI/AAAAAAAAAiA/cuxukps-XZU/s1600/Tasklist.JPG

Sebastian Menski

unread,
May 8, 2015, 5:03:41 AM5/8/15
to camunda-...@googlegroups.com, karl-hein...@gmx.at
Hi Karl,

the name of the tasks is given by the BPMN XML file. Its the name attribute. Isn't it a option for you to directly translate it inside the BPMN XML?

Cheers,
Sebastian

Karl-Heinz Stöckler

unread,
May 8, 2015, 6:19:50 AM5/8/15
to camunda-...@googlegroups.com, karl-hein...@gmx.at
Hi Sebastian,

so you mean that I add the translate Attribute to the BPMN XML?

<bpmn2:userTask id="UserTask_4" camunda:assignee="${initiator}" camunda:formKey="embedded:app:forms/chooseOption.html" name="Choose Option test" translate="xyz">

I tried it but I get an error that the translate Attribute is not allowed:
12:18:14,897 SEVERE [org.camunda.bpm.engine.impl.interceptor.CommandContext] (ServerService Thread Pool -- 407) Error while closing command context: org.camunda.bpm.engine.ProcessEngineException: cvc-complex-type.3.2.2: Attribute 'translate' is not allowed to appear in element 'bpmn2:userTask'. | webstore.bpmn | line 106 | column 192

    at org
.camunda.bpm.engine.impl.util.xml.Parse.throwExceptionForErrors(Parse.java:188) [camunda-engine-7.2.0.jar:7.2.0]
    at org
.camunda.bpm.engine.impl.bpmn.parser.BpmnParse.execute(BpmnParse.java:247) [camunda-engine-7.2.0.jar:7.2.0]
    at org
.camunda.bpm.engine.impl.bpmn.deployer.BpmnDeployer.deploy(BpmnDeployer.java:106) [camunda-engine-7.2.0.jar:7.2.0]
    at org
.camunda.bpm.engine.impl.persistence.deploy.DeploymentCache.deploy(DeploymentCache.java:58) [camunda-engine-7.2.0.jar:7.2.0]
    at org
.camunda.bpm.engine.impl.persistence.entity.DeploymentManager.insertDeployment(DeploymentManager.java:44) [camunda-engine-7.2.0.jar:7.2.0]...

Thanks
Karl

Sebastian Menski

unread,
May 8, 2015, 7:07:35 AM5/8/15
to camunda-...@googlegroups.com, karl-hein...@gmx.at
Hi Karl,

no I meant the content of the name attribute. So just translate the name in the BPMN file itself. But of course this isn't a solution if you want to have multilingual
tasklist. I'm not aware of a solution directly in the tasklist for translating task names.

Cheers,
Sebastian

Karl-Heinz Stöckler

unread,
May 9, 2015, 9:20:20 AM5/9/15
to camunda-...@googlegroups.com, karl-hein...@gmx.at
Hi,

so that means it is not possible to have multilingual Tasknames?

Thanks
Karl

Jaap Sperling

unread,
May 10, 2015, 1:11:57 AM5/10/15
to camunda-...@googlegroups.com
Hi, not sure if the below is a solution to the issue you're facing, but on the off-chance, here is how I handle i18n of tasks.

Our application has Camunda embedded and we provide our own view on the list of tasks. The prime view for tasks is the list of tasks assigned to specific users, and we display the name and description of each task in the user's preferred language (if supported -- we even have a system where user can define their own description and names, in various languages, but that's too much detail for here). So, a user with German as preferred language will get a task with a name in German and a description in German.

In the process definition, add a UserTask with a tasklistener defined on the 'create' event, which calls a class that extends org.camunda.bpm.engine.delegate. Implement the #notify(DelegateTask) method to modify the delegateTask's name and description (and other fields you care to) with the text you want to. (Don't forget that this class is instantiated only once, and the reused, so it shouldn't contain any state, or that you have to reinitialise the state each time notify is called.)

If I need to present the user with different language version of a form, instead of defining a 'camunda:formKey' attribute on the userTask, I define a 'camunda:formHandlerClass' attribute, the value of which is a class that extends DefaultTaskFormHandler and overrides the #setFormKey(ExecutionEntity, Expression, String) method to pick the form for the user's language choice.

Hope this helps

Jaap

Karl-Heinz Stöckler

unread,
May 11, 2015, 1:14:54 AM5/11/15
to camunda-...@googlegroups.com
Hi Jaap,

can you please provide some example code for this part:

In the process definition, add a UserTask with a tasklistener defined on the 'create' event, which calls a class that extends org.camunda.bpm.engine.
delegate. Implement the #notify(DelegateTask) method to modify the delegateTask's name and description (and other fields you care to) with the text you want to.

For the second part:

If I need to present the user with different language version of a form, instead of defining a 'camunda:formKey' attribute on the userTask, I define a 'camunda:formHandlerClass' attribute, the value of which is a class that extends DefaultTaskFormHandler and overrides the #setFormKey(ExecutionEntity, Expression, String) method to pick the form for the user's language choice.
What I do for getting different languages in the taskform is, to define key value pairs in the en.json, de.json,... Files of camunda and then just use the language tag in the embedded Forms. Is this still possible? or do I have to use the FormHandler as you did?

Thank you
Karl

Jaap Sperling

unread,
May 13, 2015, 3:51:26 AM5/13/15
to camunda-...@googlegroups.com
First, in your process definition add something like

       
<userTask id="task4711" name="Assign i18n Task" camunda:formHandlerClass="com.example.MyI18nFormHandler">
           
<extensionElements>
               
<camunda:taskListener event="create" class="com.example.AssignI18nTask" />
           
</extensionElements>
       
</userTask>
       


       
Then, add the class that is invoked when the execution reaches this user task

public class AssignI18nTask implements org.camunda.bpm.engine.delegate.TaskListener {

   
@Override
   
public void notify(DelegateTask delegateTask) {
       
String language = determineLanguageForAssignee(); // however you do that
        delegateTask
.setName(getTaskNameInLanguage(language); // from resource bundle?
        delegateTask
.setDescription(getTaskDescriptionInLanguage(language)); // same...
       
...
   
}
}



Then, add the class form handler, which is called when the execution flow must work out which form to present to the user

public class MyI18nFormHandler extends org.camunda.bpm.engine.impl.form.handler.DefaultTaskFormHandler {

   
@Override
   
public TaskFormData createTaskForm(TaskEntity task) {
       
String language = determineLanguageForViewer(); // again, up to you how
        task
.getTaskDefinition().setFormKey(
               
new FixedValue("my/forms/some_" + language + ".form");
       
return super.createTaskForm(task);
   
}
}



I use HTML form (snippets), and define one for each language, with the TaskFormHandler just modifying the "formKey" attribute at runtime.

Hope this helps,

Jaap

Karl-Heinz Stöckler

unread,
May 17, 2015, 8:53:17 AM5/17/15
to camunda-...@googlegroups.com
Hi Jaap,

thanks for your Help!
I could manage to localize my tasknames now :)

Thanks
Karl
Reply all
Reply to author
Forward
0 new messages