1

to localize a Movilizer application (provide multi language support) I am using the following Method to replace the placeholders of a screen:

$global:setPlaceholders = function(key)
{
    fieldNames = getMasterdata($masterdata:"localisation", key);
    fieldNames = fieldNames["data"];

    for(entry : fieldNames)
    {
        setPlaceholder(concat("%", entry, "%"), fieldNames[entry]);
    }
};

<answer ... >
    <text>%KEY%</text>
</answer>
<onEnterAssignment>
    call($global:setPlaceholders)("process1.screen1");
</onEnterAssignment>

with the localized MasterData

<MovilizerRequest ... >
  <masterdataPoolUpdate pool="localisation">
    <update key="InventoryManagement.StartScreen" group="DEFAULT">
    <language language="en_us"> 
        <data>
            <entry name="KEY">
                <valstr>Entry</valstr>
            </entry>
        </data>
    </language>

    <language language="de"> 
        <data>
            <entry name="KEY">
                <valstr>Eingabe</valstr>
            </entry>
        </data>
    </language>
    </update>
  </masterdataPoolUpdate>
</MovilizerRequest>

Is there a better more standard way to localize Movilizer applications?

Pavel Kotlov
  • 544
  • 4
  • 11
  • It depends a bit on the requirements. This approach depends on the language used during participant registration. Switching languages on the fly becomes tricky then. If switching is not required then fine. Masterdata creation requires a default language though – André Schäfer Jun 27 '16 at 18:47

1 Answers1

2

Other useful methods in terms of Localization tasks:

    $global:getLocale = function(pool, key)
    {
        fieldNames = getMasterdata($masterdata:"localisation", pool);
        fieldNames = fieldNames["data"];

        return fieldNames[key];
    };
    $global:getLocaleWithReplacement = function(pool, key, replacement)
    {
        fieldNames = getMasterdata($masterdata:"localisation", pool);
        fieldNames = fieldNames["data"];
        locale = fieldNames[key];
        locale = strReplace(locale, "%1%", replacement);
        return locale;
    };
    $global:getLocaleWithReplacementArray = function(pool, key, replacement)
    {
        fieldNames = getMasterdata($masterdata:"localisation", pool);
        fieldNames = fieldNames["data"];
        locale = fieldNames[key];
        for(i : replacement)
        {
            placeholder = concat("%", i, "%");
            locale = strReplace(locale, placeholder, replacement[i]);
        }
        return locale;
    };
    $global:getLocalizedList = function(pool, key)
    {
        fieldNames = getMasterdata($masterdata:"localisation", pool);
        fieldNames = fieldNames["data"];

        filterValues = fieldNames[key];
        filterValues = strtokenarray(filterValues, ";");

        for(i : filterValues)
        {
            filter[i] = filterValues[i];
        }
        return filter;
    };

On the fly language switching

Well if language switching without re configuring and synchronization is required the solution is not that far from what is described here. What is needed to be done is:

  1. create and set a global language variable

  2. adjust the MasterData in a way that you have several language sub arrays in the data part of a key and adjust the methods accordingly.

You will not even need to change the method signature.

Localizing Movelet names work like this:

<nameExpression>
  call($global:getLocaleWithReplacementArray)("process.movelet", "MOVELET_TITLE", {0 : $global:amount;1 : $global:unit})
</nameExpression>
Pavel Kotlov
  • 544
  • 4
  • 11