2017-10-09 114 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}部分。 –