如何在Grails radioGroup中使用i18n?

时间:2015-06-02 06:31:21

标签: grails radio-button gsp

如何在messages.properties中设置消息以获取翻译的标签? (我在Grails 2.4.4上)

域:

int handledBy    

messages.properties:

Case.handledBy.1=Handled by A
Case.handledBy.2=Handled by B```   

查看:

<g:radioGroup name="handledBy" values="[1,2]">
    <tr class="prop">
        <td valign="top" class="name">
           <label><g:message code="${it.label}" />:</label>
        </td>
        <td valign="top" class="value ${hasErrors(bean:CaseInstance,field:'handledBy','errors')}">                               
            ${it.radio}
        </td>
   </tr>
</g:radioGroup>    

1 个答案:

答案 0 :(得分:2)

您可以使用g:radioGroup标记的labels属性,例如

<g:radioGroup name="handledBy" values="[1, 2]" labels="['Case.handledBy.1', 'Case.handledBy.2']">
    ...
    <label><g:message code="${it.label}"/>:</label>
    ...
</g:radioGroup>

并在messages.properties

中添加消息
Case.handledBy.1=Handled by A
Case.handledBy.2=Handled by B