See differences (only) with the following snippet which assumes the
correct/original properties in messages.properties ('englisch').
It will create a property file for the missing keys for 'de' (german)
and shows which original keys are unused
public static void main(String[] args) throws IOException {
new CheckI18N().start();
}
public void start() throws IOException {
Properties english = new Properties();
english.load(getClass().getResourceAsStream("messages.properties"));
Properties de = new Properties();
de.load(getClass().getResourceAsStream("messages_de.properties"));
// replace FastMap with LinkedHashMap
Set<String> deKeys = FastSet.newInstance();
Map<String, String> missingInDE = new TreeMap();
Set<String> unusedInDE = FastSet.newInstance();
for (Entry<Object, Object> entry : de.entrySet()) {
deKeys.add(entry.getKey().toString());
}
for (Entry<Object, Object> entry : english.entrySet()) {
if (!deKeys.contains(entry.getKey().toString()))
missingInDE.put(entry.getKey().toString(),
entry.getValue().toString());
}
for (String deKey : deKeys) {
if (english.get(deKey) == null)
unusedInDE.add(deKey);
}
System.out.println("en:" + english.size());
System.out.println("de:" + deKeys.size());
System.out.println("missing in de:" + missingInDE.size());
System.out.println("unused in de:" + unusedInDE.size());
System.out.println("\n\n==================\nmissing in de:\n");
outAsProperties(missingInDE);
System.out.println("\n\n==================\nunused in de:\n");
for (String str : unusedInDE) {
System.out.println(str);
}
}
public void outAsProperties(Map<String, String> map) {
for (Entry<String, String> entry : map.entrySet()) {
System.out.println(entry.getKey() + "=" + entry.getValue());
}
}
in the process of expanding the number of languages my wicket
application is available in, I'm running into the question of tracking
properties files.
In particular, I want to be able to get some kind of feedback about
missing translations; mismatches between property files would be
sufficient.
How do you do this? Is there a maven plugin that I've missed, or
perhaps a standalone tool?
cheers, Frank
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]