fioriアプリには約10個のタイルがあり、共有ファイルを/ commonに配置します。次の画像は、プロジェクトの構造を示しています(/ analytics、/ appsettings ...は/ commonを除くすべてのタイルです)。
多くのi18nはタイル間で同じなので、すべてのi18nを/ commonに保持したいと思います。
/analytic/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();
}
/ common / 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}}"
}
結果:
私は何をすべきか?
title
Component.jsに設定するAPIがないようです:https://sapui5.hana.ondemand.com/#/api/sap.ui.core.UIComponent
によって修正されました
"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ファイルの場所をロードする方法です:https://github.com/SAP/openui5/blob/c014e24356497a44125c1dd5419fdf536119600e/src/sap.ui.core/src/sap/ui/core/Manifest.js#L200
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加