Skip to content

Commit

Permalink
Fix build 💚
Browse files Browse the repository at this point in the history
- Fix failing test ✅
  • Loading branch information
ndegwamartin committed Jun 19, 2024
1 parent f8ba5a8 commit 854eb20
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,7 @@ private static void mergeContent(
objectMapper.readTree(Files.newBufferedReader(inputFilePath, StandardCharsets.UTF_8));

// Load the translation properties
Properties translationProperties = new Properties();
try (FileInputStream fileInputStream = new FileInputStream(translationFile);
InputStreamReader reader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8)) {

translationProperties.load(reader);
}
Properties translationProperties = getPropertiesFile(translationFile);

// Traverse and update the JSON structure
JsonNode updatedJson = updateJson(rootNode, translationProperties, locale, targetFields);
Expand All @@ -240,6 +235,20 @@ private static void mergeContent(
String.format("Merged JSON saved to \u001b[36m%s\u001b[0m", inputFilePath.toString()));
}

public static Properties getPropertiesFile(String propertiesFilePath) throws IOException {
Properties properties = new Properties();
// Read existing properties file, if it exists
if (Files.exists(Paths.get(propertiesFilePath))) {
try (FileInputStream fileInputStream = new FileInputStream(propertiesFilePath);
InputStreamReader reader =
new InputStreamReader(fileInputStream, StandardCharsets.UTF_8)) {

properties.load(reader);
}
}
return properties;
}

private static JsonNode updateJson(
JsonNode node, Properties translationProperties, String locale, Set<String> targetFields)
throws NoSuchAlgorithmException {
Expand Down Expand Up @@ -407,17 +416,8 @@ private static void extractContent(
throw new RuntimeException("Provide a valid `resourceFile` directory or file.");
}

// Read existing properties file, if it exists
Properties existingProperties = new Properties();

if (Files.exists(propertiesFilePath)) {
Properties existingProperties = getPropertiesFile(propertiesFilePath.toString());

try (FileInputStream fileInputStream = new FileInputStream(propertiesFilePath.toFile());
InputStreamReader input =
new InputStreamReader(fileInputStream, StandardCharsets.UTF_8)) {
existingProperties.load(input);
}
}
// Merge existing properties with new properties
existingProperties.putAll(textToHash);
writePropertiesFile(existingProperties, translationFile);
Expand Down
2 changes: 1 addition & 1 deletion efsity/src/test/resources/strings_fr.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Thu Nov 02 09:51:17 EAT 2023
b989b9027fad22ec89690367614e2da6=Raison de l?examen abdominal
f89de0a4cd9317a2987dfc2546e2da5e=Examen abdominal effectué
f89de0a4cd9317a2987dfc2546e2da5e=Examen abdominal effectué
bafd7322c6e97d25b6299b5d6fe8920b=Non
93cba07454f06a4a960172bbd6e2a435=Oui

0 comments on commit 854eb20

Please sign in to comment.