You can use translate in OCL to display a string in the current user's language when a matching SysTranslation entry exists.
What translate does
String.translate looks up the string in SysTranslation for the user's language.
- When a translation exists, the operator returns the translated value.
- When no translation exists, the operator returns the original string.
This fallback means that a missing translation does not leave the user without text.
Use the operator
Call translate on the string you want to display.
'Bonjour'.translate
Example
Assume that SysTranslation contains a translation from Bonjour to Hello for English users.
| Expression | User language | Returned value |
|---|---|---|
'Bonjour'.translate
|
English | Hello
|
'Bonjour'.translate
|
A language with no matching translation | Bonjour
|
Translation fallback
Use the original text as the value passed to translate. It is also the text users see when no translation has been defined. For example, if no translation is available for 'Save', 'Save'.translate returns Save.
For information about managing translated text, see Localization.
