Translations & Cleanup

This commit is contained in:
Konloch 2021-07-18 12:11:34 -07:00
parent f6ce37f439
commit 3349dd65b7
8 changed files with 50 additions and 22 deletions

View file

@ -22,6 +22,7 @@ import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer
import the.bytecode.club.bytecodeviewer.obfuscators.mapping.Refactorer;
import the.bytecode.club.bytecodeviewer.plugin.PluginWriter;
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import the.bytecode.club.bytecodeviewer.util.*;
import the.bytecode.club.bytecodeviewer.resources.importing.ImportResource;
@ -67,7 +68,6 @@ import static the.bytecode.club.bytecodeviewer.util.MiscUtils.guessLanguage;
* http://the.bytecode.club
*
* TODO BUGS:
* + Switching from Dark to System theme crashes (DarkLAF 2.6.1 works fine)
* + View>Visual Settings>Show Class Methods
* + Spam-clicking the refresh button will cause the swing thread to deadlock (Quickly opening resources used to also do this)
* This is caused by the ctrlMouseWheelZoom code, a temporary patch is just removing it worst case
@ -667,7 +667,7 @@ public class BytecodeViewer
MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - Reset Workspace",
"Are you sure you want to reset the workspace?" +
"\n\rIt will also reset your file navigator and search.",
new String[]{"Yes", "No"});
new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()});
if (dialogue.promptChoice() != 0)
return;

View file

@ -55,7 +55,7 @@ public class Constants
BCVDir.mkdirs();
//hides the BCV directory
if (!BCVDir.isHidden() && isWindows())
if (isWindows() && !BCVDir.isHidden())
{
try {
BytecodeViewer.sm.pauseBlocking();

View file

@ -49,8 +49,8 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
public class KrakatauDecompiler extends InternalDecompiler
{
public String quick() {
public String buildCLIArguments()
{
if (Configuration.library.isEmpty())
return "";
@ -74,20 +74,19 @@ public class KrakatauDecompiler extends InternalDecompiler
return TranslatedStrings.YOU_NEED_TO_SET_YOUR_PYTHON_2_PATH.toString();
ExternalResources.getSingleton().rtCheck();
if (Configuration.rt.isEmpty()) {
if (Configuration.rt.isEmpty())
{
BytecodeViewer.showMessage(TranslatedStrings.YOU_NEED_TO_SET_YOUR_JAVA_RT_PATH_A
+ "\r\n" + TranslatedStrings.YOU_NEED_TO_SET_YOUR_JAVA_RT_PATH_B);
ExternalResources.getSingleton().selectJRERTLibrary();
}
if (Configuration.python2.isEmpty()) {
BytecodeViewer.showMessage("You need to set Python!");
return "Set your paths";
}
if (Configuration.rt.isEmpty()) {
BytecodeViewer.showMessage("You need to set RT.jar!");
return "Set your paths";
if (Configuration.rt.isEmpty())
{
BytecodeViewer.showMessage(TranslatedStrings.YOU_NEED_TO_SET_YOUR_JAVA_RT_PATH_A
+ "\r\n" + TranslatedStrings.YOU_NEED_TO_SET_YOUR_JAVA_RT_PATH_B);
return TranslatedStrings.YOU_NEED_TO_SET_YOUR_JAVA_RT_PATH_A
+ " " + TranslatedStrings.YOU_NEED_TO_SET_YOUR_JAVA_RT_PATH_B;
}
String s = ExceptionUI.SEND_STACKTRACE_TO_NL;
@ -106,7 +105,7 @@ public class KrakatauDecompiler extends InternalDecompiler
"-skip", //love you storyyeller <3
"-nauto",
"-path",
Configuration.rt + ";" + krakatauTempJar.getAbsolutePath() + quick(),
Configuration.rt + ";" + krakatauTempJar.getAbsolutePath() + buildCLIArguments(),
"-out",
krakatauTempDir.getAbsolutePath(),
cn.name + ".class"
@ -194,7 +193,7 @@ public class KrakatauDecompiler extends InternalDecompiler
"-skip", //love you storyyeller <3
"-nauto",
"-path",
Configuration.rt + ";" + tempJar.getAbsolutePath() + quick(),
Configuration.rt + ";" + tempJar.getAbsolutePath() + buildCLIArguments(),
"-out",
tempDirectory.getAbsolutePath(),
cn.name + ".class"

View file

@ -30,6 +30,7 @@ import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
import the.bytecode.club.bytecodeviewer.resources.IconResources;
import the.bytecode.club.bytecodeviewer.resources.exporting.Export;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJCheckBoxMenuItem;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJRadioButtonMenuItem;
import the.bytecode.club.bytecodeviewer.util.*;
@ -803,7 +804,7 @@ public class MainViewerGUI extends JFrame
{
MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - Reload Resources",
"Are you sure you wish to reload the resources?",
new String[]{"Yes", "No"});
new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()});
if (dialogue.promptChoice() == 0)
{
@ -865,7 +866,7 @@ public class MainViewerGUI extends JFrame
{
MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - Exit",
"Are you sure you want to exit?",
new String[]{"Yes", "No"});
new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()});
if (dialogue.promptChoice() == 0)
{

View file

@ -30,6 +30,10 @@ import java.util.HashSet;
public enum TranslatedStrings
{
PRODUCTNAME("BytecodeViewer"),
PRODUCT_NAME("Bytecode Viewer"),
PRODUCT_H_NAME("Bytecode-Viewer"),
EDITABLE,
JAVA,
PROCYON,
@ -47,6 +51,9 @@ public enum TranslatedStrings
DISASSEMBLER,
RESULTS,
SEARCH,
YES,
NO,
ERROR2,
PROCESS2,
EXIT_VALUE_IS,
@ -85,14 +92,20 @@ public enum TranslatedStrings
nameSet.add(s.name());
}
private String text;
private final String TEXT_ERROR = "FAILED_TO_LOAD";
private String text = TEXT_ERROR;
TranslatedStrings(String text)
{
this.text = text;
}
TranslatedStrings()
{
//load english translations by default
try
{
this.text = Language.ENGLISH.getTranslation().get(name());
setText(Language.ENGLISH.getTranslation().get(name()));
}
catch (IOException e)
{
@ -102,6 +115,16 @@ public enum TranslatedStrings
public void setText(String text)
{
if(text == null)
{
System.err.println("TranslatedStrings:"+name() + " - Missing Translation");
text = TEXT_ERROR;
}
text = text.replace("%PRODUCTNAME%", PRODUCTNAME.toString())
.replace("%PRODUCT_NAME%", PRODUCT_NAME.toString())
.replace("%PRODUCT-NAME%", PRODUCT_H_NAME.toString());
this.text = text;
}

View file

@ -4,6 +4,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
@ -49,7 +50,7 @@ public class DialogueUtils
{
MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - Overwrite File",
"Are you sure you wish to overwrite this existing file?",
new String[]{"Yes", "No"});
new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()});
if (dialogue.promptChoice() == 0) {
file.delete();

View file

@ -6,6 +6,7 @@ import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
@ -100,7 +101,7 @@ public class VersionChecker implements Runnable
{
MultipleChoiceDialogue overwriteDialogue = new MultipleChoiceDialogue("Bytecode Viewer - Overwrite File",
"The file " + file + " exists, would you like to overwrite it?",
new String[]{"Yes", "No"});
new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()});
if (overwriteDialogue.promptChoice() != 0)
return;

View file

@ -118,8 +118,11 @@
"NEW_JAVASCRIPT_PLUGIN": "New Javascript Plugin",
"SUGGESTED_FIX_DECOMPILER_ERROR": "Suggested Fix: Click refresh class, if it fails again try another decompiler.",
"SUGGESTED_FIX_COMPILER_ERROR": "Suggested Fix: Try View>Pane>Krakatau>Bytecode and enable Editable.",
"COMPILER_TIP": "Keep in mind most decompilers cannot produce compilable classes",
"DRAG_CLASS_JAR": "Drag class/jar/zip/APK/DEX here",
"YES": "Yes",
"NO": "No",
"ERROR2": "Error:",
"PROCESS2": "Process:",
"EXIT_VALUE_IS": "Exit Value is:",