Plugins 如何在Grails插件中使用I18N消息

Plugins 如何在Grails插件中使用I18N消息,plugins,grails,internationalization,Plugins,Grails,Internationalization,我在插件中添加了一个新的异常: class UnzipException extends RuntimeException { String message String defaultMessage String fileName } . . . else { throw new UnzipException( message:"grailsant.unzipexception.badfile"

我在插件中添加了一个新的异常:

class UnzipException extends RuntimeException {
    String message
    String defaultMessage
    String fileName
}

. . .

        else {
            throw new UnzipException(
                message:"grailsant.unzipexception.badfile",
                defaultMessage: "Invalid zip file: ${zipFile}",
                fileName: zipFile)
        }
...
在插件的messages.properties中,我有:

grailsant.unzipexception.badfile=Invalid zip file: {0}
两个问题:

  • 如何用文件名填写{0}

  • 应用程序能否覆盖grailsant.unzipexception.badfile消息

  • (1) 这似乎必须由应用程序完成:

    try {
      . . .
    } catch (org.grails.plugins.grailsant.UnzipException e) {
         flash.message = e.message
         flash.args    = [e.fileName]
         flash.defaultMessage = e.defaultMessage
    }
    
    (2) 是的,如果应用程序中的message.properties与插件具有相同的键,则将使用应用程序的值