The simplest way to inject resource bundle messages into tag attributes is to use the Action's getText method. Another way is to edit the tag templates to use the resource bundle by default.
Calling getText
Code Block |
---|
<ww<saf:textfield label="%{getText('i18nlabel.labelfirstName')}" name="label1firstName" />
|
This will get the localized text message for The getText
method will look for an entry in the resource bundle with the key "i18nlabel.keyfirstName" and put it in the label., and the value of the "firstName" property will be provided by the Action, or some other object on the Value Stack.
Ediing the Templates
If using the resource bundle is the default for your application, you might consider modifying the Alternatively, portion of controlheader-core.ftl
in / template/xhtml could be modified (if xhtml . If the xhtml
theme is being used), as follows :-, the original template is found at {{/template/xhtml}.
Code Block |
---|
title | controlheader-core.ftl |
---|
|
Code Block |
---|
${parameters.label?html}:<#t/>
|
Code Block |
---|
<#assign mm="getText('"+parameters.label?html+"')" /><#t/>
${stack.findValue(mm)}:<#t/>
|
or
Code Block |
---|
${stack.findValue("getText('"+parameters.label?html+"')")}
|
such that using text tag like following will work as well (such that the label printed will be i18n)After making the change, tags with a label attribute will use the value you set as a key.
Code Block |
---|
<ww<saf:textfield label="i18nlabel.labelfirstName" name="label1firstName" />
|