本地化Movilizer应用程序(提供多语言支持)我使用以下方法替换屏幕的占位符:
$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>
使用本地化的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>
是否有更好的标准方法来本地化Movilizer应用程序?
答案 0 :(得分:2)
其他有用的方法就本地化任务而言:
$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;
};
即时语言切换
如果需要语言切换而不需要重新配置和同步,那么解决方案与此处描述的不同。需要做的是:
创建并设置全局语言变量
以一种键的数据部分中有多个语言子数组的方式调整MasterData,并相应地调整方法。
您甚至不需要更改方法签名。
本地化Movelet名称的工作方式如下:
<nameExpression>
call($global:getLocaleWithReplacementArray)("process.movelet", "MOVELET_TITLE", {0 : $global:amount;1 : $global:unit})
</nameExpression>