Do not override existing nodes

This commit is contained in:
Marcel Haßlinger 2021-03-15 15:42:37 +01:00
parent f4f1416322
commit 32c2eb20b4

View File

@ -113,8 +113,13 @@ public class JsonTranslatorIO implements TranslatorIO {
// Try to go one level deeper // Try to go one level deeper
JsonObject childObject = entry.getValue().getAsJsonObject(); JsonObject childObject = entry.getValue().getAsJsonObject();
LocalizedNode childrenNode = new LocalizedNode(key, new ArrayList<>()); LocalizedNode childrenNode = data.getChildren(key);
if(childrenNode == null) {
childrenNode = new LocalizedNode(key, new ArrayList<>());
data.addChildren(childrenNode); data.addChildren(childrenNode);
}
readTree(locale, childObject, childrenNode); readTree(locale, childObject, childrenNode);
} catch(IllegalStateException e) { // Reached end for this node } catch(IllegalStateException e) { // Reached end for this node
@ -128,6 +133,8 @@ public class JsonTranslatorIO implements TranslatorIO {
Map<String, String> messages = leafNode.getValue(); Map<String, String> messages = leafNode.getValue();
messages.put(locale, entry.getValue().getAsString()); messages.put(locale, entry.getValue().getAsString());
leafNode.setValue(messages); leafNode.setValue(messages);
System.out.println("updated key + " + key + "de locale: " + messages.get("locale-de"));
} }
} }
} }