SAP Screen Personas
Create: Dominik Ofenloch
Last Update: Regina Sheynblat
Scripting: Translation of scripts
SAP SCREEN PERSONAS KNOWLEDGE BASE - by Regina Sheynblat , Dominik Ofenloch
Personas Flavors are translatable. For example you can use the Personas Editor to change the label/text of an input field and use the flavor admin tool for the label translation afterwards. Furthermore you can also translate the flavor name, the flavor description and dropdown-listboxes in Personas. Up to now it was not possible to translate scripts in the admin tool. This article describes new feature of Screen Personas 3.0 allowing translate text in script code.
There is possibility to translate some text inside script code. This process is divided in three steps:
- Insert in script special translation prefix ‘$FLVRT:’ along with unique ID within flavor scope.
- Translate inserted ID’s to range of supported languages using flavor admin tool. The translation is performed in the same view where all other flavor control translations are done.
- In runtime backed will replace ‘$FLVRT:<ID>’ with translated text depending on current language.
Step 1: Writing translatable scripts
In order to create script which contain translatable text special sequence of characters should be used- ‘$FLVRT:<ID>’ where <ID> is unique ID of translatable text. Unique means in a scope of flavor. Later this id will be used in translation tool to find correct translation for each language. Also this id will be displayed in flavor admin tool translation screen. Here are some examples of scripts with translatable text:
session.utils.alert("Some text $FLVRT:UD2");
session.utils.alert("$FLVRT:UD3 and some text");
session.utils.alert("Some text $FLVRT:UD4 and some text");
In these script lines unique ids UD1, UD2, UD3 and UD4 are used. Special character sequence ‘$FLVRT:<ID>’ can be at any place in script but it should always end with space character or double quote.
Step 2: Translating script to different languages
After you have saved script code, inserted IDs are available for translation in flavor admin tool. When opening translation screen IDs from all flavor scripts are listed in Translation table. “Type” is set to “Script text symbol” but “Item Key” is ID.
Now it is necessary fill “Target text” column with appropriate translations for every supported language. Initially “Source text” column is empty, but when source language is set as target language and “Target text” is filled the “Source text” column is filled with actual translation.
Step 3: Runtime
In runtime backend replaces ‘$FLVRT:<ID>’ with translated text in current active language.
For example in for scripts in previous example the runtime script code passed to browser in English language will be following:
session.utils.alert("This is UD1");
session.utils.alert("Some text This is UD2");
session.utils.alert("This is UD3 and some text");
session.utils.alert("Some text and some text");
If there is no translation for given ID in current language then empty string is used as translated text.
Related SAP Notes/KBAs
2050325 - SAP Screen Personas 3.0 : Released Notes Information