1

本地化 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 应用程序?

4

1 回答 1

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;
    };

即时语言切换

好吧,如果需要在不重新配置和同步的情况下切换语言,那么解决方案与此处描述的相差不远。需要做的是:

  1. 创建并设置全局语言变量

  2. 调整 MasterData 的方式是在键的数据部分中有多个语言子数组,并相应地调整方法。

您甚至不需要更改方法签名。

本地化 Movelet 名称的工作方式如下:

<nameExpression>
  call($global:getLocaleWithReplacementArray)("process.movelet", "MOVELET_TITLE", {0 : $global:amount;1 : $global:unit})
</nameExpression>
于 2016-06-30T22:27:15.120 回答