cleanup for "fix: pootle does not like translations in line number 0"
[gigi.git] / util-testing / org / cacert / gigi / localisation / TranslationCollectingVisitor.java
index 472789d8750e147e6dc15022e607cbc3f9ef963a..16f7c41f0070e8c5f125a8c3803f81b34093cc95 100644 (file)
@@ -1,4 +1,6 @@
 package org.cacert.gigi.localisation;
+import java.io.File;
+import java.io.IOException;
 import java.lang.reflect.Method;
 
 import org.eclipse.jdt.internal.compiler.ASTVisitor;
@@ -123,12 +125,17 @@ public final class TranslationCollectingVisitor extends ASTVisitor {
                                        lineEnds.length - 1);
 
                        String content = new String(((StringLiteral) e).source());
-                       translationCollector.add(
-                                       content,
-                                       new String(unit.compilationResult.fileName)
-                                                       .substring(translationCollector.base
-                                                                       .getAbsolutePath().length() + 1)
-                                                       + ":" + lineNumber);
+                       File f0 = new File(new String(unit.compilationResult.fileName))
+                                       .getAbsoluteFile();
+                       File f2 = translationCollector.base.getAbsoluteFile();
+                       try {
+                               translationCollector.add(content, f0.getCanonicalPath()
+                                               .substring(f2.getCanonicalPath().length() + 1)
+                                               + ":"
+                                               + lineNumber);
+                       } catch (IOException e1) {
+                               e1.printStackTrace();
+                       }
                        return;
                }