ksc
ksc

Reputation: 53

SAPUI5: i18n property content in html tags within xml views

How to include i18n property content in html tags within xml views, i.e. a "normal" text tag in the xml view would look like this:

<Text text="Lorem ipsum"/>

with i18n property e.g.:

<Text text="{i18n>LOREMIPSUM}"/>

How to include the "{i18n>LOREMIPSUM}" for ?

<html:p> </html:p>

Thanks

Upvotes: 0

Views: 2558

Answers (2)

Jpsy
Jpsy

Reputation: 20852

Use this code in your XML view...

<HTML xmlns="sap.ui.core" content="{i18n>myHtmlContent}" />

and something like this in your i18n.properties...

myHtmlContent=<p>This is an example of <b>internationalized HTML</b> text.</p>

It is very important that the HTML string is fully encapsulated into some outer tag (in this case <p>...</p>). The HTML control will NOT work correctly, if it contains any text outside of tags.

The beauty of this approach is, that you do not have to escape any special characters in HTML. Escaping would in fact be necessary, if you would place the HTML directly into the content attribute in XML. Placing it in i18n.properties instead makes the whole HTML content a lot easier to manage.

Upvotes: 1

c_y
c_y

Reputation: 550

You can use core:html tag to add HTML . I am not sure how to bind it to html:p . But, the following code works.

<core:HTML
 content='&lt;div &gt;{i18n&gt;LOREMIPSUM}&lt;/div&gt;'>
</core:HTML>

Upvotes: 0

Related Questions