dev@glassfish.java.net

checking for unused i18n keys in resource files

From: Bobby Bissett <Robert.Bissett_at_Sun.COM>
Date: Mon, 19 Oct 2009 15:25:25 -0400

Speaking of logging (from another thread)....

I was going to ask if there was a tool to check props files against
source code to look for unused i18n keys, but it was almost as easy
just to write one myself. If anyone is interested in trying it, I've
attached it. It should be self-explanatory what you need to do; just
check the top of the file for things to set (directory names, file
extensions, etc). I found >20 unused keys in the upgrade tool, which
isn't surprising since it's been simplified so much.

If you're not on Windows, you probably have Python somewhere and can
edit/run the file right away. Otherwise, you can download Python,
download Jython, grab the Python module for NetBeans that comes with
Jython, log into a unix box, or just ask your neighbor to run it.

The only non-obvious logic in the script is that it only checks source
code that is in the same package as the resource file since that's the
way things seem to work around here. If you're using one big resource
bundle for all your packages, you'll need to tweak things or let me
know and maybe I'll get to it. This isn't meant to be a pro solution,
but just something helpful.

Disclaimer: don't go removing things from your source code based
solely on my hack....

Cheers,
Bobby