1 Reply Latest reply: Oct 27, 2010 12:47 PM by 796440 RSS

    Check for missing keys in properties files


      I am going to internationalize a project and I will be using property files. I am using Eclipse and I found out several editor plug-ins that could help me to maintain the files, however I am still missing a tool/plug-in that could help me to validate that all the references to properties files keys I use in the source code are really present in the properties files.

      For instance I have a piece of code like this:

      String helloval = ResourceBundle.getBundle("mypropfile").get("hellokey")

      and "mypropfile.properties" does not contain any "hellokey" key.

      Is there a way/tool to check this kind of errors?
        • 1. Re: Check for missing keys in properties files
          You could write some code that scans all your source files for calls to getBundle(...).get(....) to find the keys (or just use grep or sed to find them) and then scans each of your properties files to make sure every key is there.

          If you change those calls to some utility method of your own, and/or use constants or enums for the key strings, it would make it easier to find the list of keys.

          Edited by: jverd on Oct 27, 2010 10:45 AM