Reputation: 325
I have a label which display a given text coming from a String variable. This variable can have two different values and for each value I have a translated version from english to my native language stored in a property file.
I have the following code:
add(new Label("fruit", new PropertyModel(getModelObject(), "fruit.name")));
and HTML:
<wicket:panel xmlns:wicket="http://wicket.apache.org/">
<div>
<div class="row">
<div class="col-sm-6">
<div class="row">
<div class="col-sm-5">
<wicket:message key="myBasket.fruit">
</wicket:message>
</div>
<div class="col-sm-7">
<span wicket:id="fruit"></span>
</div>
</div>
</div>
</div>
</div>
</wicket:panel>
This fruit can be either apple or pear. In my property file I have a translation for both values:
apple=Apfel
pear=Birne
When I run my code, the content of my label displays in English.
How can I set the value coming from the property file based on the value of the variable?
Thank you!
Upvotes: 1
Views: 234
Reputation: 2511
take a look at class StringResourceModel. You should use it as model for your Label. See user guide.
Upvotes: 5