Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply html formatting to i18n messages

In Play! 2.0 we can pass arguments to a i18n message like this:

In my view: (message.key = task.created with arguments: firstName and a code)

<div class="alert alert-success">
<a class="close" data-dismiss="alert">×</a>
    @Messages("task.created", MyContext.currentUser().firstName, newTask.code)
</div>

My message is defined as:

task.created=<strong>{0}</strong>, your task has been saved with code {1}

I would like to see the firstName with the HTML tag strong, but instead of applying the strong tag it just printing the strong tag.

I hope you understand my question. Is this possible in Play or not?

Thanks!

like image 221
adis Avatar asked Apr 26 '12 20:04

adis


1 Answers

Do it like this:

@Html(Messages("task.created", MyContext.currentUser().firstName, newTask.code))

I hope this can help you!

like image 118
LeToNode Avatar answered Oct 21 '22 10:10

LeToNode