Skip to content

Commit

Permalink
Translation Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Konloch committed Jul 9, 2021
1 parent 6868d48 commit 743b515
Show file tree
Hide file tree
Showing 39 changed files with 127 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;

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

public final JCheckBox exact = new TranslatedJCheckBox("Exact", Translation.EXACT);
public final DefaultMutableTreeNode treeRoot = new TranslatedDefaultMutableTreeNode("Results", Translation.RESULTS);
public final TranslatedDefaultMutableTreeNode treeRoot = new TranslatedDefaultMutableTreeNode("Results", Translation.RESULTS);
public final JTree tree;
public final JComboBox typeBox;

Expand Down Expand Up @@ -126,6 +127,7 @@ public SearchBoxPane()
optionPanel.add(search, BorderLayout.SOUTH);

this.tree = new JTree(treeRoot);
treeRoot.setTree((DefaultTreeModel) tree.getModel());

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ public void loadLanguage() throws IOException

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

//update translation text value
text.value = translationMap.get(text.key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,38 @@
import the.bytecode.club.bytecodeviewer.translation.Translation;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;

/**
* @author Konloch
* @since 7/7/2021
*/
public class TranslatedDefaultMutableTreeNode extends DefaultMutableTreeNode
{
private final TranslatedComponentReference componentReference;
private DefaultTreeModel tree;

public TranslatedDefaultMutableTreeNode(String text, Translation translation)
{
super(text);

if(translation != null)
{
componentReference = translation.getTranslatedComponentReference();
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
componentReference.runOnUpdate.add(()->
{
if(componentReference.value != null && !componentReference.value.isEmpty())
setUserObject(componentReference.value);
if(componentReference.value != null && !componentReference.value.isEmpty())
{
setUserObject(componentReference.value);
if(tree != null)
tree.nodeChanged(this);
}
});
componentReference.translate();
}
else
{
componentReference = null;
}
}

public void setTree(DefaultTreeModel tree)
{
this.tree = tree;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,19 @@
*/
public class TranslatedJButton extends JButton
{
private final TranslatedComponentReference componentReference;

public TranslatedJButton(String text, Translation translation)
{
super(text);

if(translation != null)
{
componentReference = translation.getTranslatedComponentReference();
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
componentReference.runOnUpdate.add(()->
{
if(componentReference.value != null && !componentReference.value.isEmpty())
setText(componentReference.value);
});
componentReference.translate();
}
else
{
componentReference = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,19 @@
*/
public class TranslatedJCheckBox extends JCheckBox
{
private final TranslatedComponentReference componentReference;

public TranslatedJCheckBox(String text, Translation translation)
{
super(text);

if(translation != null)
{
componentReference = translation.getTranslatedComponentReference();
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
componentReference.runOnUpdate.add(()->
{
if(componentReference.value != null && !componentReference.value.isEmpty())
setText(componentReference.value);
});
componentReference.translate();
}
else
{
componentReference = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,19 @@
*/
public class TranslatedJCheckBoxMenuItem extends JCheckBoxMenuItem
{
private final TranslatedComponentReference componentReference;

public TranslatedJCheckBoxMenuItem(String text, Translation translation)
{
super(text);

if(translation != null)
{
componentReference = translation.getTranslatedComponentReference();
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
componentReference.runOnUpdate.add(()->
{
if(componentReference.value != null && !componentReference.value.isEmpty())
setText(componentReference.value);
});
componentReference.translate();
}
else
{
componentReference = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,19 @@
*/
public class TranslatedJLabel extends JLabel
{
private final TranslatedComponentReference componentReference;

public TranslatedJLabel(String text, Translation translation)
{
super(text);

if(translation != null)
{
componentReference = translation.getTranslatedComponentReference();
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
componentReference.runOnUpdate.add(()->
{
if(componentReference.value != null && !componentReference.value.isEmpty())
setText(componentReference.value);
});
componentReference.translate();
}
else
{
componentReference = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,19 @@
*/
public class TranslatedJMenu extends JMenu
{
private final TranslatedComponentReference componentReference;

public TranslatedJMenu(String text, Translation translation)
{
super(text);

if(translation != null)
{
componentReference = translation.getTranslatedComponentReference();
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
componentReference.runOnUpdate.add(()->
{
if(componentReference.value != null && !componentReference.value.isEmpty())
setText(componentReference.value);
});
componentReference.translate();
}
else
{
componentReference = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,19 @@
*/
public class TranslatedJMenuItem extends JMenuItem
{
private final TranslatedComponentReference componentReference;

public TranslatedJMenuItem(String text, Translation translation)
{
super(text);

if(translation != null)
{
componentReference = translation.getTranslatedComponentReference();
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
componentReference.runOnUpdate.add(()->
{
if(componentReference.value != null && !componentReference.value.isEmpty())
setText(componentReference.value);
});
componentReference.translate();
}
else
{
componentReference = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,19 @@
*/
public class TranslatedJRadioButtonMenuItem extends JRadioButtonMenuItem
{
private final TranslatedComponentReference componentReference;

public TranslatedJRadioButtonMenuItem(String text, Translation translation)
{
super(text);

if(translation != null)
{
componentReference = translation.getTranslatedComponentReference();
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
componentReference.runOnUpdate.add(()->
{
if(componentReference.value != null && !componentReference.value.isEmpty())
setText(componentReference.value);
});
componentReference.translate();
}
else
{
componentReference = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,19 @@
*/
public class TranslatedJTextField extends JTextField
{
private final TranslatedComponentReference componentReference;

public TranslatedJTextField(String text, Translation translation)
{
super(text);

if(translation != null)
{
componentReference = translation.getTranslatedComponentReference();
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
componentReference.runOnUpdate.add(()->
{
if(componentReference.value != null && !componentReference.value.isEmpty())
setText(componentReference.value);
});
componentReference.translate();
}
else
{
componentReference = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,19 @@
*/
public class TranslatedVisibleComponent extends VisibleComponent
{
private final TranslatedComponentReference componentReference;

public TranslatedVisibleComponent(String title, Translation translation)
{
super(title);

if(translation != null)
{
componentReference = translation.getTranslatedComponentReference();
TranslatedComponentReference componentReference = translation.getTranslatedComponentReference();
componentReference.runOnUpdate.add(()->
{
if(componentReference.value != null && !componentReference.value.isEmpty())
setTitle(componentReference.value);
});
componentReference.translate();
}
else
{
componentReference = null;
}
}
}
4 changes: 3 additions & 1 deletion src/main/resources/translations/arabic.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,7 @@
"SUGGESTED_FIX_COMPILER_ERROR": "الإصلاح المقترح: جرب View> Pane> Krakatau> Bytecode وتمكين التحرير.",
"SEARCH_REGEX": "البحث في Regex:",
"NEW_JAVASCRIPT_PLUGIN": "البرنامج المساعد الجديد لجافا سكريبت",
"NEW_JAVA_PLUGIN": "البرنامج المساعد الجديد جافا"
"NEW_JAVA_PLUGIN": "البرنامج المساعد الجديد جافا",
"SAVE_AS": "حفظ باسم ...",
"SAVE": "يحفظ..."
}
3 changes: 3 additions & 0 deletions src/main/resources/translations/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,8 @@
"OWNER": "Owner: ",
"NAME": "Name: ",
"DESC": "Desc: ",
"SAVE": "Save...",
"SAVE_AS": "Save As...",
"RESULTS": "Results",
"REFRESH": "Refresh"
}
5 changes: 4 additions & 1 deletion src/main/resources/translations/farsi.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,8 @@
"RELOAD_RESOURCES": "بارگیری مجدد منابع",
"SAVE_AS_DEX": "ذخیره به عنوان DEX ...",
"NEW_JAVASCRIPT_PLUGIN": "پلاگین Javascript جدید",
"NEW_JAVA_PLUGIN": "پلاگین جاوا جدید"
"NEW_JAVA_PLUGIN": "پلاگین جاوا جدید",
"SAVE_AS": "ذخیره به عنوان...",
"SAVE": "صرفه جویی...",
"RESULTS": "نتایج"
}
5 changes: 4 additions & 1 deletion src/main/resources/translations/finnish.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,8 @@
"RELOAD_RESOURCES": "Lataa resurssit uudelleen",
"SAVE_AS_DEX": "Tallenna nimellä DEX ...",
"NEW_JAVASCRIPT_PLUGIN": "Uusi Javascript-laajennus",
"NEW_JAVA_PLUGIN": "Uusi Java-laajennus"
"NEW_JAVA_PLUGIN": "Uusi Java-laajennus",
"SAVE_AS": "Tallenna nimellä...",
"SAVE": "Tallentaa...",
"RESULTS": "Tulokset"
}
4 changes: 3 additions & 1 deletion src/main/resources/translations/french.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,7 @@
"SUGGESTED_FIX_COMPILER_ERROR": "Solution suggérée : essayez Affichage > Volet > Krakatau > Bytecode et activez Modifiable.",
"SEARCH_REGEX": "Rechercher une expression régulière :",
"NEW_JAVASCRIPT_PLUGIN": "Nouveau plugin Javascript",
"NEW_JAVA_PLUGIN": "Nouveau plugin Java"
"NEW_JAVA_PLUGIN": "Nouveau plugin Java",
"SAVE_AS": "Enregistrer sous...",
"SAVE": "Sauvegarder..."
}
5 changes: 4 additions & 1 deletion src/main/resources/translations/georgian.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,8 @@
"RELOAD_RESOURCES": "გადატვირთეთ რესურსები",
"SAVE_AS_DEX": "შეინახეთ როგორც DEX ...",
"NEW_JAVASCRIPT_PLUGIN": "ახალი Javascript მოდული",
"NEW_JAVA_PLUGIN": "ახალი ჯავა მოდული"
"NEW_JAVA_PLUGIN": "ახალი ჯავა მოდული",
"SAVE_AS": "Შეინახე როგორც...",
"SAVE": "Გადარჩენა...",
"RESULTS": "შედეგები"
}
4 changes: 3 additions & 1 deletion src/main/resources/translations/german.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,7 @@
"NAME": "Name: ",
"SEARCH_REGEX": "Regex suchen: ",
"NEW_JAVASCRIPT_PLUGIN": "Neues Javascript-Plugin",
"NEW_JAVA_PLUGIN": "Neues Java-Plugin"
"NEW_JAVA_PLUGIN": "Neues Java-Plugin",
"SAVE_AS": "Speichern als...",
"SAVE": "Speichern..."
}
Loading

0 comments on commit 743b515

Please sign in to comment.