Wednesday, February 27, 2008

groovy script to rename a lot of files

I got a hold of 1692 mp3 files of Chinese characters for a Chinese-English dictionary that I wrote with my 16year old cousin to introduce him to programming in Groovy. The dictionary is called xiaosu cidian 小苏词典 http://www.diningphilosophers.net/xiaosu

The mp3 files are all in uppercase but I wanted them in lower case. Here's the script I wrote to do that:


new File(".").eachFile{ f->
def cmd = "mv $f.name ${f.name.toLowerCase()}"
cmd.execute()
}


Much easier than with Java!

Tuesday, February 12, 2008

internationalization (i18n) in grails

any .properties files put in grails-app/i18n can be used to store internationalized text.

for example, grails-app/i18n/foobar.properties

the internationalized text can be accessed in the view using

Monday, February 11, 2008

grails configuration file

To access a key in Config.groovy, grailsApplication.config.key

extracting html form unicode data

tomcat has problems with extracting unicode data (chinese for example) from submitted form. The form must be method="post". method="get" will not work in tomcat but works in jetty