Creatio mobile - translations

Hi,
Is there a way in Creatio mobile to reference translation labels via $context.Resources.Strings, the same way we do in JS on the Web version? I tried this, but unfortunately it doesn't work. It's possible to hardcode translations inside the mobile app, but that leaves the question of how to determine which language is currently active for the user. Is the user's active language/culture exposed anywhere in the mobile SDK?
 

Like 1

Like

3 comments
Best reply

Hello,

Yes, it is possible to reference translation labels in the Mobile application. You can retrieve them in the following ways:

1. const label = await ($context as any).getResourceString('MyResourceKey') ?? 'fallback';

This approach allows you to obtain the localized value for a specific resource key directly in code. If the resource is not found, the fallback value will be used.

2. #ResourceString(UsrName)# can be passed as title for dialog, label for button, etc via SDK. It will be resolved automatically.

 

 

Hello,

Yes, it is possible to reference translation labels in the Mobile application. You can retrieve them in the following ways:

1. const label = await ($context as any).getResourceString('MyResourceKey') ?? 'fallback';

This approach allows you to obtain the localized value for a specific resource key directly in code. If the resource is not found, the fallback value will be used.

2. #ResourceString(UsrName)# can be passed as title for dialog, label for button, etc via SDK. It will be resolved automatically.

 

 

Hi,

I checked both approaches and they work. Thanks!

Is there, however, any way to access information about the currently logged-in user and their language within the mobile app?

I just realized what my original problem actually was, and why your answer doesn't solve it :)

These solutions work when it's a label defined for the view, but they don't work at all when it's a label that refers to an object field.


[Example 1]

{
    "operation": "insert",
    "name": "TabContainer_gbg1csl",
    "values": {
        "type": "crt.TabContainer",
        "items": [],
        "caption": "#ResourceString(TabContainer_gbg1csl_caption)#",
        "iconPosition": "only-text",
        "visible": true
    },
    "parentName": "TabPanel_poiszvh",
    "propertyName": "items",
    "index": 6
},

Here we have a view label, and as you can see, it's assigned using the ResourceString macro. This works fine.

[Example 2]

{
    "operation": "insert",
    "name": "ComboBox_9ijhdyv",
    "values": {
        "layoutConfig": {
            "column": 1,
            "colSpan": 1,
            "row": 1,
            "rowSpan": 1
        },
        "type": "crt.ComboBox",
        "label": "$Resources.Strings.CaseDS_CreatedBy_lyopz5h",
        "ariaLabel": "",
        "isAddAllowed": true,
        "showValueAsLink": true,
        "labelPosition": "auto",
        "control": "$CaseDS_CreatedBy_lyopz5h"
    },
    "parentName": "GridContainer_945eip2",
    "propertyName": "items",
    "index": 0
},

Here the label is the column name. Unfortunately, in this case, none of the solutions work as expected.

Below is an example of the handler code:

await dbg($context, 'T1: ' + await $context.getResourceString('TabContainer_gbg1csl_caption')); // Correct label
await dbg($context, 'T2: ' + await $context.getResourceString('CaseDS_CreatedBy_lyopz5h')); // Incorrect label: null
await dbg($context, 'T3: #ResourceString(TabContainer_gbg1csl_caption)#'); // Correct label
await dbg($context, 'T4: #ResourceString(CaseDS_CreatedBy_lyopz5h)#'); // Incorrect label: #ResourceString(CaseDS_CreatedBy_lyopz5h)#
Show all comments