Skip to content

Commit

Permalink
Template Language Processor improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
autumoswitzerland committed Oct 2, 2024
1 parent 49eb7d6 commit 08c9eae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,16 @@ private static void processHtmlFile(Path htmlFile, Path baseDir, BufferedWriter
propertiesWriter.newLine();
// Write translations to the properties file in the form of key=value
for (Map.Entry<String, String> entry : translations.entrySet()) {
propertiesWriter.write(entry.getKey() + "=" + entry.getValue());
final String escaped = escape(entry.getValue());
if (escaped.contains("{$")) {
propertiesWriter.write("# TODO: Replace the variables with placeholders for Java message formatting ({0}, {1} etc.)");
propertiesWriter.newLine();
propertiesWriter.write("# and insert the variables as arguments in the language translation placeholders");
propertiesWriter.newLine();
propertiesWriter.write("# in the HTML template; see documentation on language management.");
propertiesWriter.newLine();
}
propertiesWriter.write(entry.getKey() + "=" + escaped);
propertiesWriter.newLine();
}
}
Expand All @@ -277,6 +286,10 @@ private static void processHtmlFile(Path htmlFile, Path baseDir, BufferedWriter
htmlWriter.write(t);
}
}

private static String escape(String entry) {
return entry.replace("'", "''");
}

private static String prettyPrint(List<Node> nodes) {
final StringBuilder result = new StringBuilder();
Expand Down

0 comments on commit 08c9eae

Please sign in to comment.