From 6669d050581285531fba38dd8a4ab38c82ee8656 Mon Sep 17 00:00:00 2001 From: Alse72 <37065389+Alse72@users.noreply.github.com> Date: Wed, 3 Jan 2024 00:02:13 +0100 Subject: [PATCH] Updated it manifest (#271) --- cleanFiles/src/Definition.java | 8 ++++---- cleanFiles/src/FileUtils.java | 8 ++------ cleanFiles/src/Property.java | 8 +++++++- cleanFiles/src/ToTranslate.java | 11 ++++++----- it/DestinyLoadoutNameDefinition.json | 6 ++++++ 5 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 it/DestinyLoadoutNameDefinition.json diff --git a/cleanFiles/src/Definition.java b/cleanFiles/src/Definition.java index e742d4c8..d096bdf2 100644 --- a/cleanFiles/src/Definition.java +++ b/cleanFiles/src/Definition.java @@ -26,15 +26,15 @@ public class Definition implements JsonObject { private final Map properties; public Definition(String lang, String fileName, final Map properties) { - this.lang = lang; + this.lang = lang.equals("en") ? "template" : lang; this.fileName = fileName; this.properties = properties; } public Definition(Path defPath, final Map properties) { - this.lang = defPath.getParent().getFileName().toString(); - this.fileName = defPath.getFileName().toString(); - this.properties = properties; + this(defPath.getParent().getFileName().toString(), + defPath.getFileName().toString(), + properties); } public String getLang() { diff --git a/cleanFiles/src/FileUtils.java b/cleanFiles/src/FileUtils.java index 6d05d72d..f0b1d78a 100644 --- a/cleanFiles/src/FileUtils.java +++ b/cleanFiles/src/FileUtils.java @@ -93,10 +93,6 @@ public static void saveJson(Path toFile, Object o) { private static Path shortenPath(Path toFile) { int len = toFile.getNameCount(); - Path toFileShort = toFile.subpath(len - 2, len); - if (toFileShort.getParent().endsWith("en")) - toFileShort = Paths.get("template", toFileShort.getFileName().toString()); - return toFileShort; + return toFile.subpath(len - 2, len); } - -} +} \ No newline at end of file diff --git a/cleanFiles/src/Property.java b/cleanFiles/src/Property.java index 845ccc71..4c0b6cc2 100644 --- a/cleanFiles/src/Property.java +++ b/cleanFiles/src/Property.java @@ -80,6 +80,8 @@ public Extended removeEmptyFields() { } } + private String name; + private String description; private DisplayProperties displayProperties; private DisplayProperties originalDisplayProperties; private Entry entry; @@ -103,7 +105,9 @@ public String getProgressDescription() { @Override public boolean isEmpty() { - return (displayProperties == null || displayProperties.isEmpty()) + return (name == null || name.isBlank()) + && (description == null || description.isBlank()) + && (displayProperties == null || displayProperties.isEmpty()) && (originalDisplayProperties == null || originalDisplayProperties.isEmpty()) && (entry == null || entry.isEmpty()) && (sourceString == null || sourceString.isBlank()) && (statName == null || statName.isBlank()) @@ -121,6 +125,8 @@ public boolean isEmpty() { @Override public Property removeEmptyFields() { + name = removeEmptyString(name); + description = removeEmptyString(description); displayProperties = (DisplayProperties) removeEmptyObj(displayProperties); originalDisplayProperties = (DisplayProperties) removeEmptyObj(originalDisplayProperties); entry = (Entry) removeEmptyObj(entry); diff --git a/cleanFiles/src/ToTranslate.java b/cleanFiles/src/ToTranslate.java index a478bc11..f725a2ed 100644 --- a/cleanFiles/src/ToTranslate.java +++ b/cleanFiles/src/ToTranslate.java @@ -1,4 +1,5 @@ import java.util.List; +import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.stream.Collectors; @@ -8,9 +9,9 @@ public class ToTranslate { private Map keysTotals; public ToTranslate(String[] langs) { - this.keysToTranslate = new LinkedHashMap<>(); - for (String lang : langs) - keysToTranslate.put(lang, new LinkedHashMap<>()); + this.keysToTranslate = new LinkedHashMap<>(langs.length); + + Arrays.asList(langs).forEach(lang -> keysToTranslate.put(lang, new LinkedHashMap<>())); this.keysTotals = new LinkedHashMap<>(langs.length); @@ -25,7 +26,7 @@ public ToTranslate(String[] langs) { keysTotals.compute(def.getLang(), (k, v) -> v == null ? 0 : v + def.getPropertySize()); }); - int templateTotal = templateDefs.stream().mapToInt(d -> d.getPropertySize()).sum(); + int templateTotal = templateDefs.stream().mapToInt(Definition::getPropertySize).sum(); Map percentages = keysTotals.entrySet().stream().collect(Collectors.toMap( Map.Entry::getKey, e -> (double) e.getValue() / templateTotal * 100, (a, b) -> a, LinkedHashMap::new)); @@ -44,4 +45,4 @@ private void removeEmpty() { keysToTranslate.forEach((k, v) -> v.entrySet().removeIf(entry -> entry.getValue().isEmpty())); keysToTranslate.entrySet().removeIf(entry -> entry.getValue().isEmpty()); } -} +} \ No newline at end of file diff --git a/it/DestinyLoadoutNameDefinition.json b/it/DestinyLoadoutNameDefinition.json new file mode 100644 index 00000000..90c56f95 --- /dev/null +++ b/it/DestinyLoadoutNameDefinition.json @@ -0,0 +1,6 @@ +{ + "2166136261": { + "name": "Salva nuova dotazione", + "description": "Salva l'equipaggiamento attuale in questo slot dotazione. Successivamente potrai equipaggiare il tuo personaggio con la dotazione salvata in questo slot." + } +} \ No newline at end of file