Patch for native2ascii not running in Grails 0.5.6 and 0.6
Due to some other improvements in Grails 0.5.x I accidentally killed native2ascii execution when producing WAR files, and it is still broken in 0.6. But here’s a fix. NOTE: this only affects "grails war".
For those unaware of the reasons for native2ascii: basically the only sane way to deal with i18n message bundles is to have them all in UTF-8 and have grails automatically convert them to 7-bit ASCII with unicode escapes. ASCII is the only format guaranteed to be read correctly no matter where you deploy your application – and its the documented format for Java properties files even though Java happily loads them using the system’s file.encoding instead of forcing us-ascii!
Anyway, Grails very smartly has done this for you for a long time, and as I said – ahem – "somebody" broke it in 0.5.x because of a change to copy files to a safe staging area when running "grails war" so that it stopped messing up your web-app/ tree.
This problem is JIRA’d and will be fixed soon in Grails SVN but for now you will want to use the following patch.
- Edit GRAILS_HOME/scripts/War.groovy
- Find the line:
Ant.copy(todir:"${basedir}/staging/WEB-INF/grails-app",
overwrite:true) {
fileset(dir:"${basedir}/grails-app",
includes:"**")
} - After that bit of code, add this:
Ant.delete(dir:"${basedir}/staging/WEB-INF/grails-app/i18n",
file:"*.properties", failonerror:true)
Ant.native2ascii(src:"${basedir}/grails-app/i18n",
dest:"${basedir}/staging/WEB-INF/grails-app/i18n",
includes:"*.properties",
encoding:"UTF-8")
No related posts.