");
- for (File file : new File(source).listFiles()) {
- if (file.isFile()) {
+ for(File i18n : new File(i18nPath).listFiles()) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("
");
+ for (File file : new File(source).listFiles()) {
sb.append(SystemUtils.LINE_SEPARATOR);
sb.append(String.format(
"");
sb.append(SystemUtils.LINE_SEPARATOR);
}
+ sb.append("
");
+ String dest = destination.substring(0, destination.lastIndexOf(".")) + "." + i18n.getName().split("\\.")[0] + ".html";
+ FileUtils.writeStringToFile(new File(dest), sb.toString());
}
- sb.append("
");
- FileUtils.writeStringToFile(new File(destination), sb.toString());
+ }
+
+ public String translate(String content, File i18n) {
+ Properties props = new Properties();
+ props.load(new FileInputStream(i18n));
+ return replace(content, props);
+ }
+
+ public String replace(String content, Properties props) {
+ Matcher m = PATTERN.matcher(content);
+ StringBuffer sb = new StringBuffer();
+ while (m.find()) {
+ String var = m.group(1);
+ Object replacement = props.get(var);
+ m.appendReplacement(sb, replacement.toString());
+ }
+ m.appendTail(sb);
+ return sb.toString();
}
}
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index 29b072ba..3f06ce33 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -15,6 +15,10 @@