Skip to content

Commit 743b515

Browse files
committed
Translation Fixes
1 parent 6868d48 commit 743b515

39 files changed

Lines changed: 127 additions & 98 deletions

src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchBoxPane.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import javax.swing.JScrollPane;
1515
import javax.swing.JTree;
1616
import javax.swing.tree.DefaultMutableTreeNode;
17+
import javax.swing.tree.DefaultTreeModel;
1718

1819
import org.objectweb.asm.tree.ClassNode;
1920
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
@@ -59,7 +60,7 @@ public class SearchBoxPane extends TranslatedVisibleComponent
5960
public static final SearchType[] SEARCH_TYPES = SearchType.values();
6061

6162
public final JCheckBox exact = new TranslatedJCheckBox("Exact", Translation.EXACT);
62-
public final DefaultMutableTreeNode treeRoot = new TranslatedDefaultMutableTreeNode("Results", Translation.RESULTS);
63+
public final TranslatedDefaultMutableTreeNode treeRoot = new TranslatedDefaultMutableTreeNode("Results", Translation.RESULTS);
6364
public final JTree tree;
6465
public final JComboBox typeBox;
6566

@@ -126,6 +127,7 @@ public SearchBoxPane()
126127
optionPanel.add(search, BorderLayout.SOUTH);
127128

128129
this.tree = new JTree(treeRoot);
130+
treeRoot.setTree((DefaultTreeModel) tree.getModel());
129131

130132
getContentPane().setLayout(new BorderLayout());
131133

src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ public void loadLanguage() throws IOException
112112

113113
//skip translating if the language config is missing the translation key
114114
if(!translationMap.containsKey(text.key))
115+
{
116+
System.err.println("MISSING TRANSLATION KEY: " + text.key);
115117
continue;
118+
}
116119

117120
//update translation text value
118121
text.value = translationMap.get(text.key);

src/main/java/the/bytecode/club/bytecodeviewer/translation/components/TranslatedDefaultMutableTreeNode.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,38 @@
44
import the.bytecode.club.bytecodeviewer.translation.Translation;
55

66
import javax.swing.tree.DefaultMutableTreeNode;
7+
import javax.swing.tree.DefaultTreeModel;
78

89
/**
910
* @author Konloch
1011
* @since 7/7/2021
1112
*/
1213
public class TranslatedDefaultMutableTreeNode extends DefaultMutableTreeNode
1314
{
14-
private final TranslatedComponentReference componentReference;
15+
private DefaultTreeModel tree;
1516

1617
public TranslatedDefaultMutableTreeNode(String text, Translation translation)
1718
{
1819
super(text);
1920

2021
if(translation != null)
2122
{
22-
componentReference = translation.getTranslatedComponentReference();
23+
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
2324
componentReference.runOnUpdate.add(()->
2425
{
25-
if(componentReference.value != null && !componentReference.value.isEmpty())
26-
setUserObject(componentReference.value);
26+
if(componentReference.value != null && !componentReference.value.isEmpty())
27+
{
28+
setUserObject(componentReference.value);
29+
if(tree != null)
30+
tree.nodeChanged(this);
31+
}
2732
});
2833
componentReference.translate();
2934
}
30-
else
31-
{
32-
componentReference = null;
33-
}
35+
}
36+
37+
public void setTree(DefaultTreeModel tree)
38+
{
39+
this.tree = tree;
3440
}
3541
}

src/main/java/the/bytecode/club/bytecodeviewer/translation/components/TranslatedJButton.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,19 @@
1111
*/
1212
public class TranslatedJButton extends JButton
1313
{
14-
private final TranslatedComponentReference componentReference;
15-
1614
public TranslatedJButton(String text, Translation translation)
1715
{
1816
super(text);
1917

2018
if(translation != null)
2119
{
22-
componentReference = translation.getTranslatedComponentReference();
20+
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
2321
componentReference.runOnUpdate.add(()->
2422
{
2523
if(componentReference.value != null && !componentReference.value.isEmpty())
2624
setText(componentReference.value);
2725
});
2826
componentReference.translate();
2927
}
30-
else
31-
{
32-
componentReference = null;
33-
}
3428
}
3529
}

src/main/java/the/bytecode/club/bytecodeviewer/translation/components/TranslatedJCheckBox.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,19 @@
2929
*/
3030
public class TranslatedJCheckBox extends JCheckBox
3131
{
32-
private final TranslatedComponentReference componentReference;
33-
3432
public TranslatedJCheckBox(String text, Translation translation)
3533
{
3634
super(text);
3735

3836
if(translation != null)
3937
{
40-
componentReference = translation.getTranslatedComponentReference();
38+
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
4139
componentReference.runOnUpdate.add(()->
4240
{
4341
if(componentReference.value != null && !componentReference.value.isEmpty())
4442
setText(componentReference.value);
4543
});
4644
componentReference.translate();
4745
}
48-
else
49-
{
50-
componentReference = null;
51-
}
5246
}
5347
}

src/main/java/the/bytecode/club/bytecodeviewer/translation/components/TranslatedJCheckBoxMenuItem.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,19 @@
2929
*/
3030
public class TranslatedJCheckBoxMenuItem extends JCheckBoxMenuItem
3131
{
32-
private final TranslatedComponentReference componentReference;
33-
3432
public TranslatedJCheckBoxMenuItem(String text, Translation translation)
3533
{
3634
super(text);
3735

3836
if(translation != null)
3937
{
40-
componentReference = translation.getTranslatedComponentReference();
38+
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
4139
componentReference.runOnUpdate.add(()->
4240
{
4341
if(componentReference.value != null && !componentReference.value.isEmpty())
4442
setText(componentReference.value);
4543
});
4644
componentReference.translate();
4745
}
48-
else
49-
{
50-
componentReference = null;
51-
}
5246
}
5347
}

src/main/java/the/bytecode/club/bytecodeviewer/translation/components/TranslatedJLabel.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,19 @@
1111
*/
1212
public class TranslatedJLabel extends JLabel
1313
{
14-
private final TranslatedComponentReference componentReference;
15-
1614
public TranslatedJLabel(String text, Translation translation)
1715
{
1816
super(text);
1917

2018
if(translation != null)
2119
{
22-
componentReference = translation.getTranslatedComponentReference();
20+
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
2321
componentReference.runOnUpdate.add(()->
2422
{
2523
if(componentReference.value != null && !componentReference.value.isEmpty())
2624
setText(componentReference.value);
2725
});
2826
componentReference.translate();
2927
}
30-
else
31-
{
32-
componentReference = null;
33-
}
3428
}
3529
}

src/main/java/the/bytecode/club/bytecodeviewer/translation/components/TranslatedJMenu.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,19 @@
2929
*/
3030
public class TranslatedJMenu extends JMenu
3131
{
32-
private final TranslatedComponentReference componentReference;
33-
3432
public TranslatedJMenu(String text, Translation translation)
3533
{
3634
super(text);
3735

3836
if(translation != null)
3937
{
40-
componentReference = translation.getTranslatedComponentReference();
38+
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
4139
componentReference.runOnUpdate.add(()->
4240
{
4341
if(componentReference.value != null && !componentReference.value.isEmpty())
4442
setText(componentReference.value);
4543
});
4644
componentReference.translate();
4745
}
48-
else
49-
{
50-
componentReference = null;
51-
}
5246
}
5347
}

src/main/java/the/bytecode/club/bytecodeviewer/translation/components/TranslatedJMenuItem.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,19 @@
2929
*/
3030
public class TranslatedJMenuItem extends JMenuItem
3131
{
32-
private final TranslatedComponentReference componentReference;
33-
3432
public TranslatedJMenuItem(String text, Translation translation)
3533
{
3634
super(text);
3735

3836
if(translation != null)
3937
{
40-
componentReference = translation.getTranslatedComponentReference();
38+
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
4139
componentReference.runOnUpdate.add(()->
4240
{
4341
if(componentReference.value != null && !componentReference.value.isEmpty())
4442
setText(componentReference.value);
4543
});
4644
componentReference.translate();
4745
}
48-
else
49-
{
50-
componentReference = null;
51-
}
5246
}
5347
}

src/main/java/the/bytecode/club/bytecodeviewer/translation/components/TranslatedJRadioButtonMenuItem.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,19 @@
2929
*/
3030
public class TranslatedJRadioButtonMenuItem extends JRadioButtonMenuItem
3131
{
32-
private final TranslatedComponentReference componentReference;
33-
3432
public TranslatedJRadioButtonMenuItem(String text, Translation translation)
3533
{
3634
super(text);
3735

3836
if(translation != null)
3937
{
40-
componentReference = translation.getTranslatedComponentReference();
38+
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
4139
componentReference.runOnUpdate.add(()->
4240
{
4341
if(componentReference.value != null && !componentReference.value.isEmpty())
4442
setText(componentReference.value);
4543
});
4644
componentReference.translate();
4745
}
48-
else
49-
{
50-
componentReference = null;
51-
}
5246
}
5347
}

0 commit comments

Comments
 (0)