如何扩展翻译?

zer*_*ing 3 sapui5

我扩展了一个标准 fiori 应用程序,我也想扩展i18n
扩展应用程序的结构如下所示:

在此输入图像描述

Component.js文件中,我注意到扩展名:

this.i2d.eam.pmnotification.create.s1.Component.extend("i2d.eam.pmnotification.create.s1.ZEAM_NTF_CRES1_EXT.Component", {
    metadata: {
        manifest: "json",
        config: {
            "sap.ca.i18Nconfigs": {
                bundleName: "i2d.eam.pmnotification.create.s1.ZEAM_NTF_CRES1_EXT.i18n.i18n"
            }
        }
    }
}); 
Run Code Online (Sandbox Code Playgroud)

但文本仍然没有被翻译。

文件内容i18n.properties

ext.createNotification=Create notification
ext.createOrder=Create order 
Run Code Online (Sandbox Code Playgroud)

和按钮,使用翻译:

<Button press="onCreateWithOrder" text="{i18n>ext.createOrder}" />
<Button press="onSave" text="{i18n>ext.createNotification}"/>  
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

fab*_*oti 5

在使用旧式“脚手架”命名空间 (sap.ca.scfld) 翻译应用程序时,我仅成功使用了“sap.ca.i18Nconfigs”。

我敢打赌您正在扩展的应用程序不是基于它的。

然后,尝试将以下调用添加到您的 Component.js 文件中

init: function() {
        UIComponent.prototype.init.apply(this, arguments);

        var oModel = new sap.ui.model.resource.ResourceModel({
            bundleUrl: "../pathToYourParentApp/i18n/i18n.properties"
        });

        oModel.enhance({
            bundleUrl: "i18n/i18n.properties"
        });

        this.setModel(oModel, "i18n");
        sap.ui.getCore().setModel(oModel, "i18n");

    }
Run Code Online (Sandbox Code Playgroud)

另外,请检查示例 https://github.com/fabiopagoti/ui5-extension