BAW localises with Localization Resources (resource bundles per language, kept in a toolkit) plus the user's locale from the browser / portal preference:
- Create a Localization Resource (toolkit > User Interface): keys with values per locale (en, de, fr…); it is edited in Process Designer or imported from properties files.
- Attach it to a coach view (the view's Variables tab > Localization Resources). Configuration option labels and hover help can then use the keys, and the view's own texts are localised by referencing the keys.
- Coach view JavaScript: there is no official API to read a resource bundle from a view's event handlers. The reliable pattern is to expose a configuration option, bind the localization key to it in the coach, and read it with this.context.options.myLabel.get("value") - the framework resolves the key for the user's locale.
// coach view "Order header": configuration option "totalLabel" (String); in the coach, its value is the localization key of the attached resource
// view JS (view handler)
var label = this.context.options.totalLabel ? this.context.options.totalLabel.get("value") : "Total";
this.context.element.querySelector(".total-label").textContent = label;
// validation messages: keep keys in the service, translate in the view - the validation error text can be a key resolved through the same option pattern
tw.system.coachValidation.addValidationError("tw.local.order.total", "validation.total.max");- Task subjects and narratives are computed once on the server when the task is created, so they cannot change per viewer: keep them locale-neutral (order number, customer name) and translate the UI, or generate the subject in the locale of the assigned team's country.
- Dates, numbers, currencies: the UI Toolkit controls format by the browser locale; set the portal / Workplace language preference so that the whole page is consistent. On the server, format explicitly with Java when generating e-mails or documents.
// server-side formatting for a generated document / e-mail in the reader's language
var loc = new Packages.java.util.Locale(tw.local.language); // "de", "fr" ... taken from the recipient's profile
var nf = Packages.java.text.NumberFormat.getCurrencyInstance(loc);
var df = Packages.java.text.DateFormat.getDateInstance(Packages.java.text.DateFormat.LONG, loc);
tw.local.totalText = nf.format(tw.local.order.total);
tw.local.dueText = df.format(tw.local.order.dueDate);
Practices: one shared localisation toolkit; keys named by feature (order.approve.title); a fallback locale (en) that has every key; testing with a user whose browser is set to each language; and no literal texts in coaches - a literal label cannot be translated later without changing the artifact.
References