Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sapui5 如何在多个tile(项目)中加载共享i18n文件?_Sapui5 - Fatal编程技术网

Sapui5 如何在多个tile(项目)中加载共享i18n文件?

Sapui5 如何在多个tile(项目)中加载共享i18n文件?,sapui5,Sapui5,我们的fiori应用程序中大约有十个互动程序,我将我的共享文件放在/common中,下图显示了项目结构(/analytics,/appsettings…是除/common之外的所有互动程序): 许多i18n在磁贴之间是相同的,因此我希望将所有i18n都保持在公共位置 在/analysis/webapp/Component.js中,我定义了i18n资源: init: function() { UIComponent.prototype.init.apply(this, arguments);

我们的fiori应用程序中大约有十个互动程序,我将我的共享文件放在/common中,下图显示了项目结构(/analytics,/appsettings…是除/common之外的所有互动程序):

许多i18n在磁贴之间是相同的,因此我希望将所有i18n都保持在公共位置

在/analysis/webapp/Component.js中,我定义了i18n资源:

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

  // resourceroots is also defined in manifest.json,
  // why I defined resourceroots thrice is another topic, it's stupid, I know
  jQuery.sap.registerModulePath("myprojectcommon", "./../../common");
  jQuery.sap.registerModulePath("myproject.common", "/myproject/resources/common/");

  myprojectcommon.util.Utils.setComponent(this);

  var setComponentCommonResource = myprojectcommon.util.Utils.setCommonResource.bind(this);

  setComponentCommonResource();
}
/公共/util/Utils:

setCommonResource: function() {
  var i18nModel = new sap.ui.model.resource.ResourceModel({
    bundleName: "myproject.common.i18n.i18n"
  });

  this.setModel(i18nModel, "i18n");
}
现在加载了公共i18n,但manifest.json中定义的i18n失败,例如

"sap.app": {
  "title": "{{appTitle}}",
  "description": "{{appDescription}}"
}
其结果是:

我该怎么办

在Component.js中似乎没有可设置
标题的API:

相关问题:

"sap.app": {
  "i18n": "./../../common/i18n/i18n.properties"
}

"sap.ui5": {
  "resourceRoots": {
    "myprojectcommon": "./../../common/"
  },
  "models": {
    "i18n": {
      "type": "sap.ui.model.resource.ResourceModel",
      "settings": {
        "bundleName": "myprojectcommon.i18n.i18n"
      }
  },
}
以下是ui5如何加载i18n文件的位置:

检查资源束上的
enchance
方法,以便可以合并两个i18n文件:
this.getModel(“i18n”).enhance(globalModel.getResourceBundle())