提交 4b83637b authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 86af6c4c
...@@ -85,7 +85,7 @@ public class Message { ...@@ -85,7 +85,7 @@ public class Message {
} }
public static JdbcSQLException getSQLException(int errorCode, String[] param) { public static JdbcSQLException getSQLException(int errorCode, String[] param) {
return getSQLException(errorCode, param); return getSQLException(errorCode, param, null);
} }
public static SQLException getSyntaxError(String sql, int index) { public static SQLException getSyntaxError(String sql, int index) {
......
...@@ -54,7 +54,7 @@ public class Doclet { ...@@ -54,7 +54,7 @@ public class Doclet {
String className = getClass(clazz.name()); String className = getClass(clazz.name());
FileWriter out = new FileWriter(fileName); FileWriter out = new FileWriter(fileName);
PrintWriter writer = new PrintWriter(new BufferedWriter(out)); PrintWriter writer = new PrintWriter(new BufferedWriter(out));
int validate; int validateXhtml;
// writer.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">"); // writer.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
// writer.println("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" /><title>"); // writer.println("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" /><title>");
writer.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"); writer.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
......
...@@ -35,7 +35,7 @@ public class PrepareTranslation { ...@@ -35,7 +35,7 @@ public class PrepareTranslation {
// convert the txt files to properties files // convert the txt files to properties files
PropertiesToUTF8.textUTF8ToProperties("src/docsrc/text/_docs_de.utf8.txt", "src/docsrc/text/_docs_de.properties"); PropertiesToUTF8.textUTF8ToProperties("src/docsrc/text/_docs_de.utf8.txt", "src/docsrc/text/_docs_de.properties");
// PropertiesToUTF8.textUTF8ToProperties("src/docsrc/text/_docs_ja.utf8.txt", "src/docsrc/text/_docs_ja.properties"); PropertiesToUTF8.textUTF8ToProperties("src/docsrc/text/_docs_ja.utf8.txt", "src/docsrc/text/_docs_ja.properties");
// create the .jsp files and extract the text in the main language // create the .jsp files and extract the text in the main language
extractFromHtml("src/docsrc/html", "src/docsrc/text", MAIN_LANGUAGE); extractFromHtml("src/docsrc/html", "src/docsrc/text", MAIN_LANGUAGE);
...@@ -46,12 +46,12 @@ public class PrepareTranslation { ...@@ -46,12 +46,12 @@ public class PrepareTranslation {
// create the translated documentation // create the translated documentation
buildHtml("src/docsrc/text", "docs/html", "en"); buildHtml("src/docsrc/text", "docs/html", "en");
buildHtml("src/docsrc/text", "docs/html", "de"); buildHtml("src/docsrc/text", "docs/html", "de");
// buildHtml("src/docsrc/text", "docs/html", "ja"); buildHtml("src/docsrc/text", "docs/html", "ja");
// convert the properies files back to utf8 text files, including the main lanuage (to be used as a template) // convert the properies files back to utf8 text files, including the main lanuage (to be used as a template)
PropertiesToUTF8.propertiesToTextUTF8("src/docsrc/text/_docs_en.properties", "src/docsrc/text/_docs_en.utf8.txt"); PropertiesToUTF8.propertiesToTextUTF8("src/docsrc/text/_docs_en.properties", "src/docsrc/text/_docs_en.utf8.txt");
PropertiesToUTF8.propertiesToTextUTF8("src/docsrc/text/_docs_de.properties", "src/docsrc/text/_docs_de.utf8.txt"); PropertiesToUTF8.propertiesToTextUTF8("src/docsrc/text/_docs_de.properties", "src/docsrc/text/_docs_de.utf8.txt");
// PropertiesToUTF8.propertiesToTextUTF8("src/docsrc/text/_docs_ja.properties", "src/docsrc/text/_docs_ja.utf8.txt"); PropertiesToUTF8.propertiesToTextUTF8("src/docsrc/text/_docs_ja.properties", "src/docsrc/text/_docs_ja.utf8.txt");
// delete temporary files // delete temporary files
File[] list = new File("src/docsrc/text").listFiles(); File[] list = new File("src/docsrc/text").listFiles();
...@@ -73,8 +73,22 @@ public class PrepareTranslation { ...@@ -73,8 +73,22 @@ public class PrepareTranslation {
throw new IOException("Translation not found: " + propName); throw new IOException("Translation not found: " + propName);
} }
Properties transProp = FileUtils.loadProperties(propName); Properties transProp = FileUtils.loadProperties(propName);
// overload with this language for(Iterator it = transProp.keySet().iterator(); it.hasNext(); ) {
prop.putAll(transProp); String key = (String) it.next();
String t = transProp.getProperty(key);
// overload with translations, but not the ones starting with #
if(!t.startsWith("#")) {
prop.put(key, t);
}
}
// add spaces to each token
for(Iterator it = prop.keySet().iterator(); it.hasNext(); ) {
String key = (String) it.next();
String t = prop.getProperty(key);
prop.put(key, " " + t + " ");
}
ArrayList fileNames = new ArrayList(); ArrayList fileNames = new ArrayList();
for(int i=0; i<list.length; i++) { for(int i=0; i<list.length; i++) {
String name = list[i].getName(); String name = list[i].getName();
...@@ -238,6 +252,7 @@ public class PrepareTranslation { ...@@ -238,6 +252,7 @@ public class PrepareTranslation {
|| "span".equals(name)) { || "span".equals(name)) {
// keep tags if wrapped, but not if this is the wrapper // keep tags if wrapped, but not if this is the wrapper
if (buff.length() > 0) { if (buff.length() > 0) {
buff.append(' ');
buff.append(parser.getToken().trim()); buff.append(parser.getToken().trim());
ignoreEnd = false; ignoreEnd = false;
} else { } else {
...@@ -279,6 +294,7 @@ public class PrepareTranslation { ...@@ -279,6 +294,7 @@ public class PrepareTranslation {
} else { } else {
if(buff.length() > 0) { if(buff.length() > 0) {
buff.append(parser.getToken()); buff.append(parser.getToken());
buff.append(' ');
} }
} }
} else { } else {
...@@ -367,8 +383,7 @@ public class PrepareTranslation { ...@@ -367,8 +383,7 @@ public class PrepareTranslation {
} }
} }
Properties p = FileUtils.loadProperties(main.getAbsolutePath()); Properties p = FileUtils.loadProperties(main.getAbsolutePath());
Properties base = FileUtils.loadProperties(baseDir + "/" Properties base = FileUtils.loadProperties(baseDir + "/" + main.getName());
+ main.getName());
PropertiesToUTF8.storeProperties(p, main.getAbsolutePath()); PropertiesToUTF8.storeProperties(p, main.getAbsolutePath());
for (int i = 0; i < translations.size(); i++) { for (int i = 0; i < translations.size(); i++) {
File trans = (File) translations.get(i); File trans = (File) translations.get(i);
...@@ -380,31 +395,55 @@ public class PrepareTranslation { ...@@ -380,31 +395,55 @@ public class PrepareTranslation {
private static void prepare(Properties main, Properties base, File trans) private static void prepare(Properties main, Properties base, File trans)
throws IOException { throws IOException {
Properties p = FileUtils.loadProperties(trans.getAbsolutePath()); Properties p = FileUtils.loadProperties(trans.getAbsolutePath());
Properties oldTranslations = new Properties();
for(Iterator it = base.keySet().iterator(); it.hasNext(); ) {
String key = (String) it.next();
String m = base.getProperty(key);
String t = p.getProperty(key);
if(!t.startsWith("#")) {
oldTranslations.setProperty(m, t);
}
}
// add missing keys, using # and the value from the main file // add missing keys, using # and the value from the main file
Iterator it = main.keySet().iterator(); Iterator it = main.keySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
String key = (String) it.next(); String key = (String) it.next();
String now = main.getProperty(key); String now = main.getProperty(key);
if (!p.containsKey(key)) { if (!p.containsKey(key)) {
String t = oldTranslations.getProperty(now);
if(t == null) {
System.out System.out
.println(trans.getName() .println(trans.getName()
+ ": key " + ": key "
+ key + key
+ " not found in translation file; added dummy # 'translation'"); + " not found in translation file; added dummy # 'translation'");
p.put(key, "#" + now); t = "#" + now;
}
p.put(key, t);
} else { } else {
String t = p.getProperty(key);
String last = base.getProperty(key); String last = base.getProperty(key);
if (last != null && !last.equals(now)) { if (t.startsWith("#")) {
// not translated before
t = oldTranslations.getProperty(now);
if(t == null) {
t = "#" + now;
}
p.put(key, t);
} else if (last != null && !last.equals(now)) {
t = oldTranslations.getProperty(now);
if(t == null) {
// main data changed since the last run: review translation // main data changed since the last run: review translation
System.out.println(trans.getName() + ": key " + key System.out.println(trans.getName() + ": key " + key
+ " changed; last=" + last + " now=" + now); + " changed, please review; last=" + last + " now=" + now);
String old = p.getProperty(key); String old = p.getProperty(key);
p.put(key, "#" + now + " #" + old); t = "#" + now + " #" + old;
}
p.put(key, t);
} }
} }
} }
// remove keys that don't exist in the main file (deleted or typo in the // remove keys that don't exist in the main file (deleted or typo in the key)
// key)
it = new ArrayList(p.keySet()).iterator(); it = new ArrayList(p.keySet()).iterator();
while (it.hasNext()) { while (it.hasNext()) {
String key = (String) it.next(); String key = (String) it.next();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论