Globalising custom Workflow for Umbraco tasks
This post details how to globalise custom Workflow for Umbraco. If you haven't already done so you may benefit from watching the introductory tasks screencast in this blog post and also the screencast on how to create custom tasks in this blog post.
In the screencast below I'll demonstrate how to Globalise the Twitter task so that it's Ui properties are displayed depending on the culture of the Umbraco back office user.
All of the code in the screencast can be downloaded from the workflow samples bitbucket repository.
To summarise the screencast:
- When the workflow runtime instantiates a task it will check whether the task implements IGlobalisable
- If it does then it will pass an instance of IGlobalisationService to the task using the TheGlobalisationService property
- The task can then call the GetString method to retrieve UI text
- When adding Ui Properties to the Entity UI you can use the CreateGlobalisedObject helper to pass a GlobalisationService to your Ui Properties.
- This is done pre-constructor to enable you to use the GlobalisationService in constructor logic.
- You can replace the default application IGlobalisationService implementation should you wish.
To set up Workflow UI languages:
- Take a copy of ~/config/fmworkflow/workflow.en-GB.spring.config
- Rename it to match the Culture you are creating a UI for e.g. workflow.da-DK.spring.config
- In your file add your language text and ensure that the object name has a unique ID.
- Load your file in workflow.spring.config
- Register your culture in workflow.globalisation.spring
- Recycle your App pool