Skip to main content

Specific String Types

Header

Level: Catalog

Keywords: string types, templating, translate strings, template strings, combined strings

The result: overview of specific string types used in SAMO

SAMO string types​

In SAMO, there are multiple titles, subtitles, descriptions, error messages in different palces in the applicaton. Apart from the data that is stored in the database, we can configure these texts in SAMO metadata. For this purpose we can use simple, translate or template strings. It is also possible to create various combined strings.

Example of simple string:

"titleString": "Defect5001"

Example of translate string:

"titleString": "{tr:defects.title}"

Example of template string:

"titleString": "{get:#at_trDefect_title} {get:#at_boSamo_code}"

Example of combined string:

{
"titleString": "{tr:defects.title} {get:#at_boSamo_code}",
"descriptionString": "Partner Name: {get:#at_faPartner__name}",
"subTitleString": "{tr:orderTitle} {get:#at_boCnsOrder__boCnsSID.at_boSamo__code}"
}

Translate Strings​

Translate strings are used to make the translation of SAMO application into other languages easier. The configuration of metadata is the same and based on the language currently chosen by the user, it refers to specific file, where the wording of all titles, descriptions, error messages etc. is stored.

These files are stored in gateway/applications/applicationId/resources/string folder and usually named based on the specific application part and with the suffix of specific language (e.g. common_en.json, defects_de.json). They also need to be referenced in the application.json under localizationResources. The content corresponds to simple json files, where key refers to the configuration which is used in SAMO metadata and is the same for all languages and value is the actual wording of title, error message etc. It is possible to create hierarchies using keys with object values containing other key-value pairs.

common_en.json - configuration example
{
"common": {
"login": "Login",
"logout": "Logout",
"save": "Save",
"update_success" : "Successfully updated",
"errors" : {
"unknown" : "Something weird is going on in here"
}
}
common_de.json - configuration example
{
"common": {
"login": "Anmelden",
"logout": "Abmelden",
"save": "Speichern",
"update_success" : "Erfolgreich aktualisiert",
"errors" : {
"unknown" : "Unerwarteter Fehler"
}
}
Reference in SAMO metadata - configuration example
"title" : "{tr:common.login}"

Template strings​

Using template strings, we can compose strings using values of variable. For example, we can use feature type attributes, which can have different value for every feature, or we can use some text output of defined business action. More about template strings is described in the SAMO Lighthouse.

Debugging & Help​

Since the Dynamic-App version 6.11.2, you can validate your template strings directly in the SAMO Application. Each implementation module has function templating which can be invoked from developer console in browser.

Navigate to element in DOM element panel and in console write $0.templating(TESTING_TEMPLATED_STRING) e.g. $0.templating('{tr:badLoginPassword}').

The dataContext is automatically taken from module when using the templating function but you can also specify it. $0.templating(TESTING_TEMPLATED_STRING, DATA_CONTEXT).

Since the Dynamic-App version 7.3.6 this option is also available directly using SAMO Debugging tool.