为 Movilizer 应用程序提供 Localization/Multi 语言支持
Provide Localization/Multi language support for Movilizer Applications
本地化 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 应用程序?
其他在本地化任务方面有用的方法:
$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>
本地化 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 应用程序?
其他在本地化任务方面有用的方法:
$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>