Grails在外部JavaScript文件中的messages.properties中设置错误消息

时间:2015-12-15 12:10:46

标签: javascript java grails internationalization formvalidation-plugin

如何在 messages.properties 文件中的外部java脚本文件上设置错误消息,以便根据英语,德语等本地或语言自动更改错误消息。

如何在外部java脚本文件上使用 <g:message code="" default="" /> ${message(code:'',default:'')}

1 个答案:

答案 0 :(得分:0)

在我的应用程序中,我通过以下方式将模型对象传递给javascript:

<g:javascript>
    // Scroll the page to the position of the add button clicked by the user
    jQuery(document).ready(function() {
            window.scrollBy(0, ${pageScroll}); 
        });     
</g:javascript>

在您的示例中,您可以使用标记

定义新变量
<g:set var="tranlsatedLabel" value="${g.message(..)}"/> 

你可以像我上面所说的那样传递它。