-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have a message, in a variable selectedMessage, and in the object, I have a message type coming from the DB, which is a String value, for example, OPERATIONAL . So, now, I want to translate this value to another language, so I have the labels in the file, as:
app.user.messages.type.OPERATIONAL=Operacional
Is there any way to load that value?
I've tried several things, but non worked... like:
<label value="${ c:cat('labels.app.user.messages.type.', vmApp.selectedMessage.msgType) }"/>
<label value="${ c:l(c:cat('labels.app.user.messages.type.', vmApp.selectedMessage.msgType)) }"/>
<label value="@load(c:l(c:cat('labels.app.user.messages.type.', vmApp.selectedMessage.msgType)) )"/>
Thanks in advance
how about using the labels variable. Since it represents the labels as nested maps you can access properties dynamically using the square brackets labels.app[propertyExpression] and an expression resulting in a string (indirect reference):
<label value="@load(labels.app.user.messages.type[vmApp.selectedMessage.msgType])"/>
or if reused more often on a page you can use @ref to make it more readable and improve performance (PE/EE only):
<div msgLabels="@ref(labels.app.user.messages)" selMsg="@ref(vmApp.selectedMessage)">
<label value="@load(msgLabels.type[selMsg.msgType])"/>
<label value="@load(msgLabels.status[selMsg.msgStatus])"/>
<label value="@load(msgLabels.somethingElse[selMsg.msgSomethingElse])"/>
</div>
Robert
Well, I finally found a way, so I'm gonna reply my own question.
Here it is, as the last example not working that I provided, when you use the l taglib, you don't need the labels. part
<label value="@load(c:l(c:cat('app.user.messages.type.', vmApp.selectedMessage.msgType)) )"/>
Asked: 2017-09-04 16:05:34 +0800
Seen: 25 times
Last updated: Sep 07 '17
zkspringmvc jar licence is GPL ?
Build web application without any zul files
Custom component that extends Textbox does not fire onChange event
java.lang.NullPointerException to update to zk 8.0.1
"Spring Session" + ZK + "Spring core" @Listen method refresh the screen
zk8 client side binding to a viewmodel command seems not to work
upload event dialog do not open in browser
Notification is not shown inside sticky block
Where can I find documentation (like ZK Developer's Reference) for ZK 8.0.2.2 ?