我有一个代码,用于检查服务器的响应并根据收到的信息显示消息框。我有2种语言的这些消息(用户在登录时选择一种语言)。这是示例:
if(sResponse == 'IDfail'){
sap.m.MessageBox.alert
("{i18nResourceModel>idnotnine}",
{icon: sap.m.MessageBox.Icon.ERROR,
title: "{i18nResourceModel>error}"}
);
}
这是i18n模型声明(当然是在使用模型之前声明的):
var oResourceModel = new sap.ui.model.resource.ResourceModel
({bundleUrl: "i18n/i18n.properties", bundleLocale: "en"});
sap.ui.getCore().setModel(oResourceModel, "i18nResourceModel");
我有2个.properties
文件:(i18n.properties
英语)和i18n_iw.properties
(希伯来语)。
奇怪的是,title
消息框的正确翻译了,但是我看到的不是消息本身,而是文本:“ i18nResourceModel> idnotnine”。
之前效果很好,我不知道发生了什么。
是什么导致此问题,如何解决?
谢谢你。
数据绑定通常无法在像这样的函数调用中起作用sap.m.MessageBox.alert()
。您必须手动获取文本,例如:
var resourceModel = sap.ui.getCore().getModel("i18nResourceModel");
var alertText = resourceModel.getProperty("idnotnine");
var alertTitle = resourceModel.getProperty("error");
sap.m.MessageBox.alert(alertText, {
icon: sap.m.MessageBox.Icon.ERROR,
title: alertTitle
}
);
另外,您可以在此处查看有关如何使用ResourceBundle的最新指南。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句