added consistence check for enum language keys

This commit is contained in:
hneemann 2017-07-06 10:31:27 +02:00
parent b3a3a25438
commit 7c46da19e8
2 changed files with 18 additions and 2 deletions

View File

@ -68,7 +68,7 @@ public class Key<VALUE> {
* @return the keys description
*/
public String getDescription() {
String d=Lang.getNull(langKey + "_tt");
String d = Lang.getNull(langKey + "_tt");
if (d != null)
return d;
else
@ -162,7 +162,17 @@ public class Key<VALUE> {
names = new String[values.length];
for (int i = 0; i < values.length; i++)
names[i] = Lang.get("key_" + key.replace(" ", "") + "_" + values[i].name());
names[i] = Lang.get(getLangKey(values[i]));
}
/**
* creates the language key for the enum values
*
* @param value the value
* @return the language key
*/
public String getLangKey(E value) {
return getLangKey() + "_" + value.name();
}
/**

View File

@ -31,6 +31,12 @@ public class TestKeyConsistence extends TestCase {
Key key = ((Key) f.get(null));
checkKey(key.getLangKey());
checkKey(key.getLangKey() + "_tt");
if (key instanceof Key.KeyEnum) {
Key.KeyEnum ke = (Key.KeyEnum) key;
for (Enum v : ke.getValues())
checkKey(ke.getLangKey(v));
}
}
}