2017-10-09 112 views
0

我在我的项目中使用了i18n文件。我需要大胆地处理属性“missingItems”的占位符中的文本。这是酒店需要从国际化:如何在SAPUI5中以粗体显示占位符文本

missingItems = The items: {0} are missing! 

控制器:

var missingItemsArray= ["item1", "item2", "item3"] 
var sMessage = this.getView().getModel("i18n").getResourceBundle().getText("missingItems", [missingItemsArray]); 
      MessageBox.show(sMessage, { 
       icon: MessageBox.Icon.WARNING, 
       title: "exampleTitle", 
       actions: [sap.m.MessageBox.Action.OK], 
       id: "messageBoxId2", 
       defaultAction: sap.m.MessageBox.Action.OK, 
       details: "exampleDetails" 
      }); 

任何帮助将不胜感激! :)

回答

1

你应该使用组件FormattedText这样的:

的I18n

missingItems = The items: <strong>{0}</strong> are missing! 

控制器

var missingItemsArray= ["item1", "item2", "item3"]; 
var sMessage = this.getView().getModel("i18n").getResourceBundle().getText("missingItems", [missingItemsArray]); 
var formattedText = new sap.m.FormattedText("FormattedText", { 
    htmlText: sMessage 
}); 
MessageBox.show(formattedText, { 
    icon: MessageBox.Icon.WARNING, 
    title: "exampleTitle", 
    actions: [sap.m.MessageBox.Action.OK], 
    id: "messageBoxId2", 
    defaultAction: sap.m.MessageBox.Action.OK, 
    details: "exampleDetails" 
}); 

示例:https://sapui5.hana.ondemand.com/#/sample/sap.m.sample.FormattedText/code/C.controller.js

+0

谢谢巴勃罗! –

0
font-weight: bold 

它添加到大胆的占位符文本

+0

我应该在哪里放置它? –

+0

你可以在你的css或javascript中做到这一点 – kappo

+0

但是,这将改变整个文本。我只想粗体显示它的{0}部分。 –