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?
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:
create and set a global language variable
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>