From 4da585c64209edfadf644622937e46b83a47eb14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Ha=C3=9Flinger?= Date: Thu, 4 Nov 2021 10:20:03 +0100 Subject: [PATCH] implement addLocale method and clarify children methods --- .../de/marhali/easyi18n/model/TranslationData.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/marhali/easyi18n/model/TranslationData.java b/src/main/java/de/marhali/easyi18n/model/TranslationData.java index 0b10263..ba042b2 100644 --- a/src/main/java/de/marhali/easyi18n/model/TranslationData.java +++ b/src/main/java/de/marhali/easyi18n/model/TranslationData.java @@ -58,6 +58,13 @@ public class TranslationData { return this.locales; } + /** + * @param locale Adds the provided locale to the supported languages list + */ + public void addLocale(@NotNull String locale) { + this.locales.add(locale); + } + /** * @return root node which contains all translations */ @@ -105,7 +112,7 @@ public class TranslationData { * @param fullPath Absolute translation key path * @param translation Translation to set. Can be null to delete the corresponding node */ - public void setTranslation(@NotNull String fullPath, @Nullable Translation translation) throws Exception { + public void setTranslation(@NotNull String fullPath, @Nullable Translation translation) { List sections = this.pathUtil.split(fullPath); String nodeKey = sections.remove(sections.size() - 1); // Edge case last section TranslationNode node = this.rootNode; @@ -123,7 +130,7 @@ public class TranslationData { } // Created nested section - childNode = node.addChildren(section); + childNode = node.setChildren(section); } node = childNode; @@ -137,7 +144,7 @@ public class TranslationData { } } else { // Create or overwrite - node.addChildren(nodeKey, translation); + node.setChildren(nodeKey, translation); } }