From 09fb0cf7953597ac53ae9a3a68273e5539bd352d Mon Sep 17 00:00:00 2001 From: Honfika Date: Fri, 3 Jan 2014 15:56:12 +0100 Subject: [PATCH] missing localizations 2 --- .../decompiler/flash/abc/ScriptPack.java | 18 ++------------- .../flash/abc/types/MethodBody.java | 14 +++--------- .../jpexs/decompiler/flash/action/Action.java | 21 ++++++------------ trunk/src/com/jpexs/helpers/Helper.java | 22 +++++++++++++++++++ 4 files changed, 34 insertions(+), 41 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java b/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java index 149bf440a..5c0eaf9ec 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java @@ -156,26 +156,12 @@ public class ScriptPack implements TreeElementItem { } catch (TimeoutException ex) { writer.continueMeasure(); Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Decompilation error", ex); - writer.appendNoHilight("/*").newLine(); - writer.appendNoHilight(" * ").appendNoHilight(AppStrings.translate("decompilationError")).newLine(); - writer.appendNoHilight(" * ").appendNoHilight(String.format(AppStrings.translate("decompilationError.timeout"), Helper.formatTimeToText(Configuration.decompilationTimeoutFile.get()))).newLine(); - writer.appendNoHilight(" */").newLine(); - writer.appendNoHilight("throw new IllegalOperationError(\""). - appendNoHilight(AppStrings.translate("decompilationError.timeout.description")). - appendNoHilight("\");").newLine(); + Helper.appendTimeoutComment(writer, Configuration.decompilationTimeoutFile.get()); return; } catch (ExecutionException ex) { writer.continueMeasure(); Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Decompilation error", ex); - writer.appendNoHilight("/*").newLine(); - writer.appendNoHilight(" * ").appendNoHilight(AppStrings.translate("decompilationError")).newLine(); - writer.appendNoHilight(" * ").appendNoHilight(AppStrings.translate("decompilationError.obfuscated")).newLine(); - writer.appendNoHilight(" * ").appendNoHilight(AppStrings.translate("decompilationError.errorType")). - appendNoHilight(": " + ex.getClass().getSimpleName()).newLine(); - writer.appendNoHilight(" */").newLine(); - writer.appendNoHilight("throw new IllegalOperationError(\""). - appendNoHilight(AppStrings.translate("decompilationError.error.description")). - appendNoHilight("\");").newLine(); + Helper.appendErrorComment(writer, ex); return; } writer.continueMeasure(); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index 1711da1d6..8fbec4abe 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.gui.AppStrings; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.Graph; @@ -177,19 +178,10 @@ public class MethodBody implements Cloneable, Serializable { writer.endMethod(); } else if (convertException instanceof TimeoutException) { Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Decompilation error", convertException); - writer.appendNoHilight("/*").newLine(); - writer.appendNoHilight(" * Decompilation error").newLine(); - writer.appendNoHilight(" * Timeout (" + Helper.formatTimeToText(timeout) + ") was reached").newLine(); - writer.appendNoHilight(" */").newLine(); - writer.appendNoHilight("throw new IllegalOperationError(\"Not decompiled due to timeout\");").newLine(); + Helper.appendTimeoutComment(writer, Configuration.decompilationTimeoutFile.get()); } else { Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Decompilation error", convertException); - writer.appendNoHilight("/*").newLine(); - writer.appendNoHilight(" * Decompilation error").newLine(); - writer.appendNoHilight(" * Code may be obfuscated").newLine(); - writer.appendNoHilight(" * Error type: " + convertException.getClass().getSimpleName()).newLine(); - writer.appendNoHilight(" */").newLine(); - writer.appendNoHilight("throw new IllegalOperationError(\"Not decompiled due to error\");").newLine(); + Helper.appendErrorComment(writer, convertException); } writer.unindent(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java index 7c1e2f8b1..7d012c9f4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/Action.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/Action.java @@ -47,6 +47,7 @@ import com.jpexs.decompiler.flash.action.swf5.*; import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.ecma.Null; +import com.jpexs.decompiler.flash.gui.AppStrings; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; @@ -729,19 +730,10 @@ public class Action implements GraphSourceItem { Graph.graphToString(tree, writer, new LocalData()); } else if (convertException instanceof TimeoutException) { Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error", convertException); - writer.appendNoHilight("/*").newLine(); - writer.appendNoHilight(" * Decompilation error").newLine(); - writer.appendNoHilight(" * Timeout (" + Helper.formatTimeToText(timeout) + ") was reached").newLine(); - writer.appendNoHilight(" */").newLine(); - writer.appendNoHilight("throw new IllegalOperationError(\"Not decompiled due to timeout\");").newLine(); + Helper.appendTimeoutComment(writer, Configuration.decompilationTimeoutFile.get()); } else { Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error", convertException); - writer.appendNoHilight("/*").newLine(); - writer.appendNoHilight(" * Decompilation error").newLine(); - writer.appendNoHilight(" * Code may be obfuscated").newLine(); - writer.appendNoHilight(" * Error type: " + convertException.getClass().getSimpleName()).newLine(); - writer.appendNoHilight(" */").newLine(); - writer.appendNoHilight("throw new IllegalOperationError(\"Not decompiled due to error\");").newLine(); + Helper.appendErrorComment(writer, convertException); } asm.getActionSourceSuffix(writer); } @@ -888,9 +880,10 @@ public class Action implements GraphSourceItem { out = new ArrayList<>(); out.add(new CommentItem(new String[] { "", - " * Decompilation error", - " * Code may be obfuscated", - " * Error type: " + ex2.getClass().getSimpleName(), + " * " + AppStrings.translate("decompilationError"), + " * " + AppStrings.translate("decompilationError.obfuscated"), + " * " + AppStrings.translate("decompilationError.errorType") + ": " + + ex2.getClass().getSimpleName(), ""})); } outs.add(out); diff --git a/trunk/src/com/jpexs/helpers/Helper.java b/trunk/src/com/jpexs/helpers/Helper.java index 127cac7ef..0743624e1 100644 --- a/trunk/src/com/jpexs/helpers/Helper.java +++ b/trunk/src/com/jpexs/helpers/Helper.java @@ -709,4 +709,26 @@ public class Helper { } } } + + public static void appendTimeoutComment(GraphTextWriter writer, int timeout) { + writer.appendNoHilight("/*").newLine(); + writer.appendNoHilight(" * ").appendNoHilight(AppStrings.translate("decompilationError")).newLine(); + writer.appendNoHilight(" * ").appendNoHilight(String.format(AppStrings.translate("decompilationError.timeout"), Helper.formatTimeToText(timeout))).newLine(); + writer.appendNoHilight(" */").newLine(); + writer.appendNoHilight("throw new IllegalOperationError(\""). + appendNoHilight(AppStrings.translate("decompilationError.timeout.description")). + appendNoHilight("\");").newLine(); + } + + public static void appendErrorComment(GraphTextWriter writer, Throwable ex) { + writer.appendNoHilight("/*").newLine(); + writer.appendNoHilight(" * ").appendNoHilight(AppStrings.translate("decompilationError")).newLine(); + writer.appendNoHilight(" * ").appendNoHilight(AppStrings.translate("decompilationError.obfuscated")).newLine(); + writer.appendNoHilight(" * ").appendNoHilight(AppStrings.translate("decompilationError.errorType")). + appendNoHilight(": " + ex.getClass().getSimpleName()).newLine(); + writer.appendNoHilight(" */").newLine(); + writer.appendNoHilight("throw new IllegalOperationError(\""). + appendNoHilight(AppStrings.translate("decompilationError.error.description")). + appendNoHilight("\");").newLine(); + } }