Internationalize Rom class

This commit is contained in:
Dale Schultz 2020-03-29 09:44:45 -04:00
parent d475e2c524
commit eb5c46987d
2 changed files with 30 additions and 19 deletions

View File

@ -0,0 +1,10 @@
POPTABLES = Populating tables ...
ADDROUTOFBNDS = Storage address for table {0} is out of bounds.\nPlease check ECU definition file.
ECUDEFERROR = ECU Definition Error
TABLELOADERR = There was an error loading table {0}
YES = Yes
NO = No
CHKSUMINVALID = One or more ROM image Checksums is invalid. Calculate new Checksums?\n(NOTE: this will only fix the Checksums it will NOT repair a corrupt ROM image.
CHECKSUMFIX = Checksum Fix
INVLAIDCHKSUM = Checksum is invalid.\nThe ROM image may be corrupt or it has been hex edited manually.\nThe checksum can be corrected when the ROM is saved if your trust it is not corrupt.
CHKSUMFAIL = ERROR - Checksum Failed

View File

@ -31,11 +31,13 @@ import static javax.swing.JOptionPane.showOptionDialog;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import java.io.File; import java.io.File;
import java.io.Serializable; import java.io.Serializable;
import java.text.MessageFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.ResourceBundle;
import java.util.Vector; import java.util.Vector;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -51,6 +53,7 @@ import com.romraider.swing.CategoryTreeNode;
import com.romraider.swing.JProgressPane; import com.romraider.swing.JProgressPane;
import com.romraider.swing.TableFrame; import com.romraider.swing.TableFrame;
import com.romraider.swing.TableTreeNode; import com.romraider.swing.TableTreeNode;
import com.romraider.util.ResourceUtil;
import com.romraider.util.SettingsManager; import com.romraider.util.SettingsManager;
import com.romraider.xml.InvalidTableNameException; import com.romraider.xml.InvalidTableNameException;
import com.romraider.xml.TableNotFoundException; import com.romraider.xml.TableNotFoundException;
@ -58,6 +61,8 @@ import com.romraider.xml.TableNotFoundException;
public class Rom extends DefaultMutableTreeNode implements Serializable { public class Rom extends DefaultMutableTreeNode implements Serializable {
private static final long serialVersionUID = 7865405179738828128L; private static final long serialVersionUID = 7865405179738828128L;
private static final Logger LOGGER = Logger.getLogger(Rom.class); private static final Logger LOGGER = Logger.getLogger(Rom.class);
private static final ResourceBundle rb = new ResourceUtil().getBundle(
Rom.class.getName());
private RomID romID = new RomID(); private RomID romID = new RomID();
private String fileName = ""; private String fileName = "";
private File fullFileName = new File("."); private File fullFileName = new File(".");
@ -182,7 +187,7 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
// update progress // update progress
int currProgress = (int) (i / (double) tableNodes.size() * 100); int currProgress = (int) (i / (double) tableNodes.size() * 100);
progress.update("Populating tables...", currProgress); progress.update(rb.getString("POPTABLES"), currProgress);
Table table = tableNodes.get(i).getTable(); Table table = tableNodes.get(i).getTable();
try { try {
@ -203,8 +208,9 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
table.getStorageAddress() + " " + binData.length + " filesize", ex); table.getStorageAddress() + " " + binData.length + " filesize", ex);
// table storage address extends beyond end of file // table storage address extends beyond end of file
JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table), "Storage address for table \"" + table.getName() + JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table),
"\" is out of bounds.\nPlease check ECU definition file.", "ECU Definition Error", JOptionPane.ERROR_MESSAGE); MessageFormat.format(rb.getString("ADDROUTOFBNDS"), table.getName()),
rb.getString("ECUDEFERROR"), JOptionPane.ERROR_MESSAGE);
tableNodes.removeElementAt(i); tableNodes.removeElementAt(i);
i--; i--;
} catch (IndexOutOfBoundsException iex) { } catch (IndexOutOfBoundsException iex) {
@ -213,8 +219,9 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
table.getStorageAddress() + " " + binData.length + " filesize", iex); table.getStorageAddress() + " " + binData.length + " filesize", iex);
// table storage address extends beyond end of file // table storage address extends beyond end of file
JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table), "Storage address for table \"" + table.getName() + JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table),
"\" is out of bounds.\nPlease check ECU definition file.", "ECU Definition Error", JOptionPane.ERROR_MESSAGE); MessageFormat.format(rb.getString("ADDROUTOFBNDS"), table.getName()),
rb.getString("ECUDEFERROR"), JOptionPane.ERROR_MESSAGE);
tableNodes.removeElementAt(i); tableNodes.removeElementAt(i);
i--; i--;
} }
@ -227,7 +234,9 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
} catch (NullPointerException ex) { } catch (NullPointerException ex) {
LOGGER.error("Error Populating Table", ex); LOGGER.error("Error Populating Table", ex);
JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table), "There was an error loading table " + table.getName(), "ECU Definition Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(SwingUtilities.windowForComponent(table),
MessageFormat.format(rb.getString("TABLELOADERR"), table.getName()),
rb.getString("ECUDEFERROR"), JOptionPane.ERROR_MESSAGE);
tableNodes.removeElementAt(i); tableNodes.removeElementAt(i);
i--; i--;
} }
@ -337,15 +346,12 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
else if (checksum.getTable().isLocked() && else if (checksum.getTable().isLocked() &&
!checksum.getTable().isButtonSelected()) { !checksum.getTable().isButtonSelected()) {
Object[] options = {"Yes", "No"}; Object[] options = {rb.getString("YES"), rb.getString("NO")};
final String message = String.format( final String message = rb.getString("CHKSUMINVALID");
"One or more ROM image Checksums is invalid. " +
"Calculate new Checksums?%n" +
"(NOTE: this will only fix the Checksums it will NOT repair a corrupt ROM image)");
int answer = showOptionDialog( int answer = showOptionDialog(
SwingUtilities.windowForComponent(checksum.getTable()), SwingUtilities.windowForComponent(checksum.getTable()),
message, message,
"Checksum Fix", rb.getString("CHECKSUMFIX"),
DEFAULT_OPTION, DEFAULT_OPTION,
QUESTION_MESSAGE, QUESTION_MESSAGE,
null, null,
@ -434,12 +440,7 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
public void validateChecksum() { public void validateChecksum() {
if (!checksumManagers.isEmpty()) { if (!checksumManagers.isEmpty()) {
final String message = String.format( final String message = rb.getString("INVLAIDCHKSUM");
"At least one Checksum is invalid.%n" +
"The ROM image may be corrupt or it has been " +
"hex edited manually.%n" +
"The checksum can be corrected when the ROM " +
"is saved if your trust it is not corrupt.");
boolean valid = true; boolean valid = true;
@ -450,7 +451,7 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
if(!valid) if(!valid)
showMessageDialog(null, showMessageDialog(null,
message, message,
"ERROR - At least one Checksum Failed", rb.getString("CHKSUMFAIL"),
WARNING_MESSAGE); WARNING_MESSAGE);
} }
} }