Skip to main content

How to check if all the keys in a java code are in the bundle?

No replies
cile
Offline
Joined: 2006-08-18
Points: 0

Hi everyone,

We are a team who develop a software written in Java, using bundles for internationalization. We are looking for an analysis tool which can check if all the keys written in the Java Code are in the resource bundle.

This is an example about how it's hard to identify the keys :

Locale locale = new Locale("en", "EN");
ResourceBundle bundle = ResourceBundle.getBundle("MyBundle", locale);

// This is easy to check if the keys are written like this into the Java code.

String myString = bundle.getString("MyKey");

// It's also easy to check this kind of keys

String string1 = "MyKey1";
String string2 = string1;
myString = bundle.getString(string2);

// But it's very hard to check theses keys

String string3 = "MyKey2";
String string4 = string3.toLowerCase();
myString = bundle.getString(string4)

// This one too

String string5 = myfunction();
myString = bundle.getString(string5);

We can pay for a tool or for a plugin for Netbeans but open source is better. Btw this tool could also be used to find unused keys in the bundle.
Remember that the aim of this tool is to analyse Java code to get all the keys used.

Thanks you for your help

Sylvain