More Translation Support

This commit is contained in:
Konloch 2021-07-07 03:39:29 -07:00
parent 29c816c13e
commit 820a086a93
11 changed files with 101 additions and 17 deletions

View File

@ -759,6 +759,10 @@ public class MainViewerGUI extends JFrame
JMenuItem waitIcon = waitIcons.get(0);
waitIcons.remove(0);
rootMenu.remove(waitIcon);
//re-enable the Refresh Button incase it gets stuck
if(waitIcons.isEmpty() && !workPane.refreshClass.isEnabled())
workPane.refreshClass.setEnabled(true);
}
rootMenu.updateUI();

View File

@ -30,11 +30,11 @@ import javax.swing.JInternalFrame;
public abstract class VisibleComponent extends JInternalFrame
{
private static final long serialVersionUID = -6453413772343643526L;
public VisibleComponent(final String title)
{
super(title, false, false, false, false);
this.setFrameIcon(null);
}
private static final long serialVersionUID = -6453413772343643526L;
}

View File

@ -32,6 +32,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent;
import the.bytecode.club.bytecodeviewer.translation.Translation;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJCheckBox;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedVisibleComponent;
import the.bytecode.club.bytecodeviewer.util.FileContainer;
import the.bytecode.club.bytecodeviewer.util.FileDrop;
import the.bytecode.club.bytecodeviewer.util.LazyNameUtil;
@ -63,7 +64,7 @@ import the.bytecode.club.bytecodeviewer.util.LazyNameUtil;
* @since 09/26/2011
*/
public class ResourceListPane extends VisibleComponent implements FileDrop.Listener
public class ResourceListPane extends TranslatedVisibleComponent implements FileDrop.Listener
{
public final JPopupMenu rightClickMenu = new JPopupMenu();
public final JCheckBox exact = new TranslatedJCheckBox("Exact", Translation.EXACT);
@ -116,11 +117,10 @@ public class ResourceListPane extends VisibleComponent implements FileDrop.Liste
public ResourceListPane()
{
super("ClassNavigation");
super("Files", Translation.FILES);
tree.setRootVisible(false);
tree.setShowsRootHandles(true);
quickSearch.setForeground(Color.gray);
setTitle("Files");
attachTreeListeners();
attachQuickSearchListeners();

View File

@ -1,6 +1,7 @@
package the.bytecode.club.bytecodeviewer.gui.resourcelist;
import the.bytecode.club.bytecodeviewer.gui.util.StringMetricsUtil;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
@ -38,7 +39,7 @@ public class ResourceTree extends JTree
g.setColor(new Color(0, 0, 0, 100));
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.white);
String s = "Drag class/jar/zip/APK/DEX here";
String s = TranslatedStrings.DRAG_CLASS_JAR.toString();
g.drawString(s,
((int) ((getWidth() / 2) - (m.getWidth(s) / 2))),
getHeight() / 2);

View File

@ -21,7 +21,9 @@ import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer
import the.bytecode.club.bytecodeviewer.searching.BackgroundSearchThread;
import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier;
import the.bytecode.club.bytecodeviewer.translation.Translation;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJButton;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJCheckBox;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedVisibleComponent;
import the.bytecode.club.bytecodeviewer.util.FileContainer;
/***************************************************************************
@ -51,7 +53,7 @@ import the.bytecode.club.bytecodeviewer.util.FileContainer;
*/
@SuppressWarnings("rawtypes")
public class SearchBoxPane extends VisibleComponent
public class SearchBoxPane extends TranslatedVisibleComponent
{
public static final SearchRadius[] SEARCH_RADII = SearchRadius.values();
public static final SearchType[] SEARCH_TYPES = SearchType.values();
@ -64,13 +66,13 @@ public class SearchBoxPane extends VisibleComponent
public SearchType searchType = null;
public final JComboBox searchRadiusBox;
public JButton search = new JButton("Search");
public JButton search = new TranslatedJButton("Search", Translation.SEARCH);
public BackgroundSearchThread performSearchThread;
@SuppressWarnings("unchecked")
public SearchBoxPane()
{
super("Search");
super("Search", Translation.SEARCH);
final JPanel optionPanel = new JPanel(new BorderLayout());
final JPanel searchRadiusOpt = new JPanel(new BorderLayout());

View File

@ -18,6 +18,9 @@ import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.FileViewer;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer;
import the.bytecode.club.bytecodeviewer.translation.Translation;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJButton;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedVisibleComponent;
import the.bytecode.club.bytecodeviewer.util.FileContainer;
import static the.bytecode.club.bytecodeviewer.Constants.BLOCK_TAB_MENU;
@ -47,7 +50,7 @@ import static the.bytecode.club.bytecodeviewer.Constants.BLOCK_TAB_MENU;
* @author WaterWolf
* @since 09/26/2011
*/
public class WorkPaneMainComponent extends VisibleComponent
public class WorkPaneMainComponent extends TranslatedVisibleComponent
{
public final JTabbedPane tabs;
public final JPanel buttonPanel;
@ -56,8 +59,7 @@ public class WorkPaneMainComponent extends VisibleComponent
public WorkPaneMainComponent()
{
super("WorkPanel");
setTitle("Work Space");
super("Workspace", Translation.WORK_SPACE);
this.tabs = new JTabbedPane();
@ -88,6 +90,7 @@ public class WorkPaneMainComponent extends VisibleComponent
tabs.remove(1);
}
});
tabs.addMouseListener(new MouseListener()
{
@Override
@ -139,16 +142,17 @@ public class WorkPaneMainComponent extends VisibleComponent
buttonPanel = new JPanel(new FlowLayout());
refreshClass = new JButton("Refresh");
refreshClass.addActionListener((event)->{
refreshClass = new TranslatedJButton("Refresh", Translation.REFRESH);
refreshClass.addActionListener((event)->
{
refreshClass.setEnabled(false);
Thread t = new Thread(() -> new WorkPaneRefresh(event).run(), "Refresh");
t.start();
});
buttonPanel.add(refreshClass);
buttonPanel.setVisible(false);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
tabs.addContainerListener(new TabRemovalEvent());

View File

@ -102,8 +102,8 @@ public enum Language
//check if translation key has been assigned to a component,
//on fail print an error alerting the devs
if(translation.getTranslatedComponent().runOnUpdate.isEmpty()
&& TranslatedStrings.nameSet.contains(translation.name()))
if(translation.getTranslatedComponent().runOnUpdate.isEmpty())
//&& TranslatedStrings.nameSet.contains(translation.name()))
{
System.err.println("Translation Reference " + translation.name() + " is missing component attachment, skipping...");
continue;

View File

@ -29,6 +29,7 @@ public enum TranslatedStrings
DISASSEMBLER("Disassembler"),
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."),
DRAG_CLASS_JAR("Drag class/jar/zip/APK/DEX here"),
;
public static final HashSet<String> nameSet = new HashSet<>();

View File

@ -0,0 +1,36 @@
package the.bytecode.club.bytecodeviewer.translation.components;
import the.bytecode.club.bytecodeviewer.translation.TranslatedComponent;
import the.bytecode.club.bytecodeviewer.translation.Translation;
import javax.swing.*;
/**
* @author Konloch
* @since 7/7/2021
*/
public class TranslatedJButton extends JButton
{
private final TranslatedComponent component;
public TranslatedJButton(String text, Translation translation)
{
super(text);
if(translation != null)
{
this.component = translation.getTranslatedComponent();
this.component.runOnUpdate.add(this::updateText);
}
else
{
this.component = null;
}
}
public void updateText()
{
if(component != null)
setText(component.value);
}
}

View File

@ -0,0 +1,35 @@
package the.bytecode.club.bytecodeviewer.translation.components;
import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent;
import the.bytecode.club.bytecodeviewer.translation.TranslatedComponent;
import the.bytecode.club.bytecodeviewer.translation.Translation;
/**
* @author Konloch
* @since 7/7/2021
*/
public class TranslatedVisibleComponent extends VisibleComponent
{
private final TranslatedComponent component;
public TranslatedVisibleComponent(String title, Translation translation)
{
super(title);
if(translation != null)
{
this.component = translation.getTranslatedComponent();
this.component.runOnUpdate.add(this::updateText);
}
else
{
this.component = null;
}
}
public void updateText()
{
if(component != null)
setTitle(component.value);
}
}

View File

@ -107,6 +107,7 @@
"ERROR": "Error",
"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.",
"DRAG_CLASS_JAR": "Drag class/jar/zip/APK/DEX here",
"FILES": "Files",
"QUICK_FILE_SEARCH_NO_FILE_EXTENSION": "Quick file search (no file extension)",