From 8cb05d5ce0f5050f3af2f5810309b0f471c31fec Mon Sep 17 00:00:00 2001 From: Edi Morales Date: Sat, 2 Mar 2024 22:49:15 -0600 Subject: [PATCH] Adds localization feature from #29 --- src/main/java/jpass/ui/EntryDetailsTable.java | 17 +++-- src/main/java/jpass/ui/JPassFrame.java | 28 +++++--- src/main/java/jpass/ui/MessageDialog.java | 17 +++-- .../java/jpass/ui/action/MenuActionType.java | 71 +++++++++++++------ src/main/java/jpass/util/Constants.java | 55 ++++++++++++++ .../languages/Messages_en_US.properties | 48 +++++++++++++ .../languages/Messages_es_US.properties | 47 ++++++++++++ 7 files changed, 242 insertions(+), 41 deletions(-) create mode 100644 src/main/java/jpass/util/Constants.java create mode 100644 src/main/resources/resources/languages/Messages_en_US.properties create mode 100644 src/main/resources/resources/languages/Messages_es_US.properties diff --git a/src/main/java/jpass/ui/EntryDetailsTable.java b/src/main/java/jpass/ui/EntryDetailsTable.java index 16bf135..fe0ee66 100644 --- a/src/main/java/jpass/ui/EntryDetailsTable.java +++ b/src/main/java/jpass/ui/EntryDetailsTable.java @@ -45,6 +45,13 @@ import jpass.util.DateUtils; import jpass.xml.bind.Entry; +import static jpass.ui.JPassFrame.MESSAGES; +import static jpass.util.Constants.VIEW_WINDOW_CREATED; +import static jpass.util.Constants.VIEW_WINDOW_MODIFIED; +import static jpass.util.Constants.VIEW_WINDOW_TITLE; +import static jpass.util.Constants.VIEW_WINDOW_URL; +import static jpass.util.Constants.VIEW_WINDOW_USER; + /** * Table to display entry details. */ @@ -54,11 +61,11 @@ public class EntryDetailsTable extends JTable { = DateUtils.createFormatter(Configuration.getInstance().get("date.format", "yyyy-MM-dd")); private enum DetailType { - TITLE("Title", Entry::getTitle), - URL("URL", Entry::getUrl), - USER("User", Entry::getUser), - MODIFIED("Modified", entry -> DateUtils.formatIsoDateTime(entry.getLastModification(), FORMATTER)), - CREATED("Created", entry -> DateUtils.formatIsoDateTime(entry.getCreationDate(), FORMATTER)); + TITLE(MESSAGES.getString(VIEW_WINDOW_TITLE), Entry::getTitle), + URL(MESSAGES.getString(VIEW_WINDOW_URL), Entry::getUrl), + USER(MESSAGES.getString(VIEW_WINDOW_USER), Entry::getUser), + MODIFIED(MESSAGES.getString(VIEW_WINDOW_MODIFIED), entry -> DateUtils.formatIsoDateTime(entry.getLastModification(), FORMATTER)), + CREATED(MESSAGES.getString(VIEW_WINDOW_CREATED), entry -> DateUtils.formatIsoDateTime(entry.getCreationDate(), FORMATTER)); private final String description; private final Function valueMapper; diff --git a/src/main/java/jpass/ui/JPassFrame.java b/src/main/java/jpass/ui/JPassFrame.java index 69008f4..633364f 100644 --- a/src/main/java/jpass/ui/JPassFrame.java +++ b/src/main/java/jpass/ui/JPassFrame.java @@ -43,6 +43,8 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -63,6 +65,12 @@ import static jpass.ui.MessageDialog.YES_OPTION; import static jpass.ui.MessageDialog.getIcon; import static jpass.ui.MessageDialog.showQuestionMessage; +import static jpass.util.Constants.BOTTOM_MENU_ENTRIES_COUNT; +import static jpass.util.Constants.BOTTOM_MENU_ENTRIES_FOUND; +import static jpass.util.Constants.EDIT_MENU; +import static jpass.util.Constants.FILE_MENU; +import static jpass.util.Constants.HELP_MENU; +import static jpass.util.Constants.TOOLS_MENU; /** * The main frame for JPass. @@ -72,6 +80,7 @@ */ public final class JPassFrame extends JFrame { + public static ResourceBundle MESSAGES = null; private static final Logger LOG = Logger.getLogger(JPassFrame.class.getName()); private static JPassFrame instance; @@ -95,7 +104,7 @@ public final class JPassFrame extends JFrame { private final StatusPanel statusPanel; private volatile boolean processing = false; - private JPassFrame(String fileName) { + private JPassFrame(String fileName, Locale locale) { try { setIconImages(Stream.of(16, 20, 32, 40, 64, 80, 128, 160) .map(size -> getIcon("jpass", size, size).getImage()) @@ -104,6 +113,8 @@ private JPassFrame(String fileName) { LOG.log(Level.CONFIG, "Could not set application icon.", e); } + MESSAGES = ResourceBundle.getBundle("resources.languages.Messages", locale); + this.toolBar = new JToolBar(); this.toolBar.setFloatable(false); this.toolBar.add(MenuActionType.NEW_FILE.getAction()); @@ -135,7 +146,7 @@ private JPassFrame(String fileName) { this.jpassMenuBar = new JMenuBar(); - this.fileMenu = new JMenu("File"); + this.fileMenu = new JMenu(MESSAGES.getString(FILE_MENU)); this.fileMenu.setMnemonic(KeyEvent.VK_F); this.fileMenu.add(MenuActionType.NEW_FILE.getAction()); this.fileMenu.add(MenuActionType.OPEN_FILE.getAction()); @@ -150,7 +161,7 @@ private JPassFrame(String fileName) { this.fileMenu.add(MenuActionType.EXIT.getAction()); this.jpassMenuBar.add(this.fileMenu); - this.editMenu = new JMenu("Edit"); + this.editMenu = new JMenu(MESSAGES.getString(EDIT_MENU)); this.editMenu.setMnemonic(KeyEvent.VK_E); this.editMenu.add(MenuActionType.ADD_ENTRY.getAction()); this.editMenu.add(MenuActionType.EDIT_ENTRY.getAction()); @@ -164,13 +175,13 @@ private JPassFrame(String fileName) { this.editMenu.add(MenuActionType.FIND_ENTRY.getAction()); this.jpassMenuBar.add(this.editMenu); - this.toolsMenu = new JMenu("Tools"); + this.toolsMenu = new JMenu(MESSAGES.getString(TOOLS_MENU)); this.toolsMenu.setMnemonic(KeyEvent.VK_T); this.toolsMenu.add(MenuActionType.GENERATE_PASSWORD.getAction()); this.toolsMenu.add(MenuActionType.CLEAR_CLIPBOARD.getAction()); this.jpassMenuBar.add(this.toolsMenu); - this.helpMenu = new JMenu("Help"); + this.helpMenu = new JMenu(MESSAGES.getString(HELP_MENU)); this.helpMenu.setMnemonic(KeyEvent.VK_H); this.helpMenu.add(MenuActionType.LICENSE.getAction()); this.helpMenu.addSeparator(); @@ -220,7 +231,8 @@ public static JPassFrame getInstance() { public static synchronized JPassFrame getInstance(String fileName) { if (instance == null) { - instance = new JPassFrame(fileName); + Locale locale = new Locale("es", "US"); + instance = new JPassFrame(fileName, locale); } return instance; } @@ -286,9 +298,9 @@ public void refreshEntryTitleList(String selectTitle) { } if (searchCriteria.isEmpty()) { - this.statusPanel.setText("Entries count: " + entries.size()); + this.statusPanel.setText(String.format("%s: %d", MESSAGES.getString(BOTTOM_MENU_ENTRIES_COUNT), entries.size())); } else { - this.statusPanel.setText("Entries found: " + this.entryDetailsTable.getRowCount() + " / " + entries.size()); + this.statusPanel.setText(String.format("%s: %d / %d", MESSAGES.getString(BOTTOM_MENU_ENTRIES_FOUND), this.entryDetailsTable.getRowCount(), entries.size())); } } diff --git a/src/main/java/jpass/ui/MessageDialog.java b/src/main/java/jpass/ui/MessageDialog.java index 7a974ae..68ea347 100644 --- a/src/main/java/jpass/ui/MessageDialog.java +++ b/src/main/java/jpass/ui/MessageDialog.java @@ -61,6 +61,13 @@ import jpass.util.SpringUtilities; +import static jpass.ui.JPassFrame.MESSAGES; +import static jpass.util.Constants.CHANGE_PASSWORD_ENTER_PASSWORD_REQUEST; +import static jpass.util.Constants.SHOW_MESSAGE_CONFIRMATION; +import static jpass.util.Constants.SHOW_MESSAGE_ERROR; +import static jpass.util.Constants.SHOW_MESSAGE_INFORMATION; +import static jpass.util.Constants.SHOW_MESSAGE_WARNING; + /** * Utility class for displaying message dialog. * @@ -203,7 +210,7 @@ private static int showMessageDialog(final Component parent, final Object messag * @param message dialog message */ public static void showWarningMessage(final Component parent, final String message) { - showMessageDialog(parent, message, "Warning", getIcon("dialog_warning")); + showMessageDialog(parent, message, MESSAGES.getString(SHOW_MESSAGE_WARNING), getIcon("dialog_warning")); } /** @@ -213,7 +220,7 @@ public static void showWarningMessage(final Component parent, final String messa * @param message dialog message */ public static void showErrorMessage(final Component parent, final String message) { - showMessageDialog(parent, message, "Error", getIcon("dialog_error")); + showMessageDialog(parent, message, MESSAGES.getString(SHOW_MESSAGE_ERROR), getIcon("dialog_error")); } /** @@ -223,7 +230,7 @@ public static void showErrorMessage(final Component parent, final String message * @param message dialog message */ public static void showInformationMessage(final Component parent, final String message) { - showMessageDialog(parent, message, "Information", getIcon("dialog_info")); + showMessageDialog(parent, message, MESSAGES.getString(SHOW_MESSAGE_INFORMATION), getIcon("dialog_info")); } /** @@ -235,7 +242,7 @@ public static void showInformationMessage(final Component parent, final String m * @return selected option */ public static int showQuestionMessage(final Component parent, final String message, final int optionType) { - return showMessageDialog(parent, message, "Confirmation", getIcon("dialog_question"), optionType); + return showMessageDialog(parent, message, MESSAGES.getString(SHOW_MESSAGE_CONFIRMATION), getIcon("dialog_question"), optionType); } /** @@ -261,7 +268,7 @@ public static char[] showPasswordDialog(final Component parent, final boolean co boolean incorrect = true; while (incorrect) { - int option = showMessageDialog(parent, panel, "Enter Password", getIcon("dialog_lock"), OK_CANCEL_OPTION); + int option = showMessageDialog(parent, panel, MESSAGES.getString(CHANGE_PASSWORD_ENTER_PASSWORD_REQUEST), getIcon("dialog_lock"), OK_CANCEL_OPTION); if (option == OK_OPTION) { if (password.getPassword().length == 0) { showWarningMessage(parent, "Please enter a password."); diff --git a/src/main/java/jpass/ui/action/MenuActionType.java b/src/main/java/jpass/ui/action/MenuActionType.java index 9a28a03..eda7c5b 100644 --- a/src/main/java/jpass/ui/action/MenuActionType.java +++ b/src/main/java/jpass/ui/action/MenuActionType.java @@ -41,9 +41,12 @@ import jpass.ui.JPassFrame; import jpass.ui.MessageDialog; import jpass.ui.helper.EntryHelper; +import jpass.util.Constants; import jpass.xml.bind.Entry; import static javax.swing.KeyStroke.getKeyStroke; + +import static jpass.ui.JPassFrame.MESSAGES; import static jpass.ui.helper.FileHelper.exportFile; import static jpass.ui.helper.FileHelper.importFile; import static jpass.ui.helper.FileHelper.openFile; @@ -53,6 +56,28 @@ import static java.awt.event.InputEvent.CTRL_DOWN_MASK; import static java.awt.event.InputEvent.ALT_DOWN_MASK; +import static jpass.util.Constants.CHANGE_PASSWORD_PASSWORD_NOT_MODIFIED; +import static jpass.util.Constants.CHANGE_PASSWORD_SUCCESSFULLY_MODIFED; +import static jpass.util.Constants.EDIT_MENU_ADD_ENTRY; +import static jpass.util.Constants.EDIT_MENU_CLEAR_CLIPBOARD; +import static jpass.util.Constants.EDIT_MENU_COPY_PASSWORD; +import static jpass.util.Constants.EDIT_MENU_COPY_URL; +import static jpass.util.Constants.EDIT_MENU_COPY_USERNAME; +import static jpass.util.Constants.EDIT_MENU_DELETE_ENTRY; +import static jpass.util.Constants.EDIT_MENU_DUPLICATE_ENTRY; +import static jpass.util.Constants.EDIT_MENU_EDIT_ENTRY; +import static jpass.util.Constants.EDIT_MENU_FIND_ENTRY; +import static jpass.util.Constants.FILE_MENU_CHANGE_PASSWORD; +import static jpass.util.Constants.FILE_MENU_EXIT; +import static jpass.util.Constants.FILE_MENU_EXPORT_TO_XML; +import static jpass.util.Constants.FILE_MENU_IMPORT_FROM_XML; +import static jpass.util.Constants.FILE_MENU_NEW; +import static jpass.util.Constants.FILE_MENU_SAVE; +import static jpass.util.Constants.FILE_MENU_SAVE_AS; +import static jpass.util.Constants.HELP_MENU_ABOUT_JPASS; +import static jpass.util.Constants.HELP_MENU_LICENSE; +import static jpass.util.Constants.TOOLS_MENU_GENERATE_PASSWORD; + /** * Enumeration which holds menu actions and related data. * @@ -60,71 +85,71 @@ * */ public enum MenuActionType { - NEW_FILE(new AbstractMenuAction("New", getIcon("new"), getKeyStroke(KeyEvent.VK_N, CTRL_DOWN_MASK)) { + NEW_FILE(new AbstractMenuAction(MESSAGES.getString(FILE_MENU_NEW), getIcon("new"), getKeyStroke(KeyEvent.VK_N, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { createNew(JPassFrame.getInstance()); } }), - OPEN_FILE(new AbstractMenuAction("Open File...", getIcon("open"), getKeyStroke(KeyEvent.VK_O, CTRL_DOWN_MASK)) { + OPEN_FILE(new AbstractMenuAction(MESSAGES.getString(Constants.FILE_MENU_OPEN_FILE), getIcon("open"), getKeyStroke(KeyEvent.VK_O, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { openFile(JPassFrame.getInstance()); } }), - SAVE_FILE(new AbstractMenuAction("Save", getIcon("save"), getKeyStroke(KeyEvent.VK_S, CTRL_DOWN_MASK)) { + SAVE_FILE(new AbstractMenuAction(MESSAGES.getString(FILE_MENU_SAVE), getIcon("save"), getKeyStroke(KeyEvent.VK_S, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { saveFile(JPassFrame.getInstance(), false); } }), - SAVE_AS_FILE(new AbstractMenuAction("Save As...", getIcon("save_as"), null) { + SAVE_AS_FILE(new AbstractMenuAction(MESSAGES.getString(FILE_MENU_SAVE_AS), getIcon("save_as"), null) { @Override public void actionPerformed(ActionEvent ev) { saveFile(JPassFrame.getInstance(), true); } }), - EXPORT_XML(new AbstractMenuAction("Export to XML...", getIcon("export"), null) { + EXPORT_XML(new AbstractMenuAction(MESSAGES.getString(FILE_MENU_EXPORT_TO_XML), getIcon("export"), null) { @Override public void actionPerformed(ActionEvent ev) { exportFile(JPassFrame.getInstance()); } }), - IMPORT_XML(new AbstractMenuAction("Import from XML...", getIcon("import"), null) { + IMPORT_XML(new AbstractMenuAction(MESSAGES.getString(FILE_MENU_IMPORT_FROM_XML), getIcon("import"), null) { @Override public void actionPerformed(ActionEvent ev) { importFile(JPassFrame.getInstance()); } }), - CHANGE_PASSWORD(new AbstractMenuAction("Change Password...", getIcon("lock"), null) { + CHANGE_PASSWORD(new AbstractMenuAction(MESSAGES.getString(FILE_MENU_CHANGE_PASSWORD), getIcon("lock"), null) { @Override public void actionPerformed(ActionEvent ev) { JPassFrame parent = JPassFrame.getInstance(); char[] password = MessageDialog.showPasswordDialog(parent, true); if (password == null) { - MessageDialog.showInformationMessage(parent, "Password has not been modified."); + MessageDialog.showInformationMessage(parent, MESSAGES.getString(CHANGE_PASSWORD_PASSWORD_NOT_MODIFIED)); } else { parent.getModel().setPassword(password); parent.getModel().setModified(true); parent.refreshFrameTitle(); MessageDialog.showInformationMessage(parent, - "Password has been successfully modified.\n\nSave the file now in order to\nget the new password applied."); + MESSAGES.getString(CHANGE_PASSWORD_SUCCESSFULLY_MODIFED)); } } }), - GENERATE_PASSWORD(new AbstractMenuAction("Generate Password...", getIcon("generate"), getKeyStroke(KeyEvent.VK_Z, CTRL_DOWN_MASK)) { + GENERATE_PASSWORD(new AbstractMenuAction(MESSAGES.getString(TOOLS_MENU_GENERATE_PASSWORD), getIcon("generate"), getKeyStroke(KeyEvent.VK_Z, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { new GeneratePasswordDialog(JPassFrame.getInstance()); } }), - EXIT(new AbstractMenuAction("Exit", getIcon("exit"), getKeyStroke(KeyEvent.VK_F4, ALT_DOWN_MASK)) { + EXIT(new AbstractMenuAction(MESSAGES.getString(FILE_MENU_EXIT), getIcon("exit"), getKeyStroke(KeyEvent.VK_F4, ALT_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { JPassFrame.getInstance().exitFrame(); } }), - ABOUT(new AbstractMenuAction("About JPass...", getIcon("info"), getKeyStroke(KeyEvent.VK_F1, 0)) { + ABOUT(new AbstractMenuAction(MESSAGES.getString(HELP_MENU_ABOUT_JPASS), getIcon("info"), getKeyStroke(KeyEvent.VK_F1, 0)) { @Override public void actionPerformed(ActionEvent ev) { StringBuilder sb = new StringBuilder(); @@ -137,37 +162,37 @@ public void actionPerformed(ActionEvent ev) { MessageDialog.showInformationMessage(JPassFrame.getInstance(), sb.toString()); } }), - LICENSE(new AbstractMenuAction("License", getIcon("license"), null) { + LICENSE(new AbstractMenuAction(MESSAGES.getString(HELP_MENU_LICENSE), getIcon("license"), null) { @Override public void actionPerformed(ActionEvent ev) { - MessageDialog.showTextFile(JPassFrame.getInstance(), "License", "license.txt"); + MessageDialog.showTextFile(JPassFrame.getInstance(), MESSAGES.getString(HELP_MENU_LICENSE), "license.txt"); } }), - ADD_ENTRY(new AbstractMenuAction("Add Entry...", getIcon("entry_new"), getKeyStroke(KeyEvent.VK_Y, CTRL_DOWN_MASK)) { + ADD_ENTRY(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_ADD_ENTRY), getIcon("entry_new"), getKeyStroke(KeyEvent.VK_Y, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { EntryHelper.addEntry(JPassFrame.getInstance()); } }), - EDIT_ENTRY(new AbstractMenuAction("Edit Entry...", getIcon("entry_edit"), getKeyStroke(KeyEvent.VK_E, CTRL_DOWN_MASK)) { + EDIT_ENTRY(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_EDIT_ENTRY), getIcon("entry_edit"), getKeyStroke(KeyEvent.VK_E, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { EntryHelper.editEntry(JPassFrame.getInstance()); } }), - DUPLICATE_ENTRY(new AbstractMenuAction("Duplicate Entry...", getIcon("entry_duplicate"), getKeyStroke(KeyEvent.VK_K, CTRL_DOWN_MASK)) { + DUPLICATE_ENTRY(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_DUPLICATE_ENTRY), getIcon("entry_duplicate"), getKeyStroke(KeyEvent.VK_K, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { EntryHelper.duplicateEntry(JPassFrame.getInstance()); } }), - DELETE_ENTRY(new AbstractMenuAction("Delete Entry...", getIcon("entry_delete"), getKeyStroke(KeyEvent.VK_D, CTRL_DOWN_MASK)) { + DELETE_ENTRY(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_DELETE_ENTRY), getIcon("entry_delete"), getKeyStroke(KeyEvent.VK_D, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { EntryHelper.deleteEntry(JPassFrame.getInstance()); } }), - COPY_URL(new AbstractMenuAction("Copy URL", getIcon("url"), getKeyStroke(KeyEvent.VK_U, CTRL_DOWN_MASK)) { + COPY_URL(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_COPY_URL), getIcon("url"), getKeyStroke(KeyEvent.VK_U, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { JPassFrame parent = JPassFrame.getInstance(); @@ -177,7 +202,7 @@ public void actionPerformed(ActionEvent ev) { } } }), - COPY_USER(new AbstractMenuAction("Copy User Name", getIcon("user"), getKeyStroke(KeyEvent.VK_B, CTRL_DOWN_MASK)) { + COPY_USER(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_COPY_USERNAME), getIcon("user"), getKeyStroke(KeyEvent.VK_B, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { JPassFrame parent = JPassFrame.getInstance(); @@ -187,7 +212,7 @@ public void actionPerformed(ActionEvent ev) { } } }), - COPY_PASSWORD(new AbstractMenuAction("Copy Password", getIcon("keyring"), getKeyStroke(KeyEvent.VK_C, CTRL_DOWN_MASK)) { + COPY_PASSWORD(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_COPY_PASSWORD), getIcon("keyring"), getKeyStroke(KeyEvent.VK_C, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { JPassFrame parent = JPassFrame.getInstance(); @@ -197,13 +222,13 @@ public void actionPerformed(ActionEvent ev) { } } }), - CLEAR_CLIPBOARD(new AbstractMenuAction("Clear Clipboard", getIcon("clear"), getKeyStroke(KeyEvent.VK_X, CTRL_DOWN_MASK)) { + CLEAR_CLIPBOARD(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_CLEAR_CLIPBOARD), getIcon("clear"), getKeyStroke(KeyEvent.VK_X, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { EntryHelper.copyEntryField(JPassFrame.getInstance(), null); } }), - FIND_ENTRY(new AbstractMenuAction("Find Entry", getIcon("find"), getKeyStroke(KeyEvent.VK_F, CTRL_DOWN_MASK)) { + FIND_ENTRY(new AbstractMenuAction(MESSAGES.getString(EDIT_MENU_FIND_ENTRY), getIcon("find"), getKeyStroke(KeyEvent.VK_F, CTRL_DOWN_MASK)) { @Override public void actionPerformed(ActionEvent ev) { JPassFrame.getInstance().getSearchPanel().setVisible(true); diff --git a/src/main/java/jpass/util/Constants.java b/src/main/java/jpass/util/Constants.java new file mode 100644 index 0000000..2dc5a06 --- /dev/null +++ b/src/main/java/jpass/util/Constants.java @@ -0,0 +1,55 @@ +package jpass.util; + +public class Constants { + private Constants() { + // No instances can be created + } + + public static final String FILE_MENU = "menuBar.fileMenu"; + public static final String EDIT_MENU = "menuBar.editMenu"; + public static final String TOOLS_MENU = "menuBar.toolsMenu"; + public static final String HELP_MENU = "menuBar.helpMenu"; + + public static final String FILE_MENU_NEW = "fileMenu.new"; + public static final String FILE_MENU_OPEN_FILE = "fileMenu.openFile"; + public static final String FILE_MENU_SAVE = "fileMenu.save"; + public static final String FILE_MENU_SAVE_AS = "fileMenu.saveAs"; + public static final String FILE_MENU_EXPORT_TO_XML = "fileMenu.exportToXML"; + public static final String FILE_MENU_IMPORT_FROM_XML = "fileMenu.importFromXML"; + public static final String FILE_MENU_CHANGE_PASSWORD = "fileMenu.changePassword"; + public static final String FILE_MENU_EXIT = "fileMenu.exitMenu"; + + public static final String CHANGE_PASSWORD_ENTER_PASSWORD_REQUEST = "changePassword.enterPasswordRequest"; + public static final String CHANGE_PASSWORD_PASSWORD_NOT_MODIFIED = "changePassword.passwordNotModified"; + public static final String CHANGE_PASSWORD_SUCCESSFULLY_MODIFED = "changePassword.successfullyModified"; + + public static final String EDIT_MENU_ADD_ENTRY = "editMenu.addEntry"; + public static final String EDIT_MENU_EDIT_ENTRY = "editMenu.editEntry"; + public static final String EDIT_MENU_DUPLICATE_ENTRY = "editMenu.duplicateEntry"; + public static final String EDIT_MENU_DELETE_ENTRY = "editMenu.deleteEntry"; + public static final String EDIT_MENU_COPY_URL = "editMenu.copyURL"; + public static final String EDIT_MENU_COPY_USERNAME = "editMenu.copyUserName"; + public static final String EDIT_MENU_COPY_PASSWORD = "editMenu.copyPassword"; + public static final String EDIT_MENU_CLEAR_CLIPBOARD = "editMenu.clearClipboard"; + public static final String EDIT_MENU_FIND_ENTRY = "editMenu.findEntry"; + + public static final String TOOLS_MENU_GENERATE_PASSWORD = "toolsMenu.generatePassword"; + + public static final String HELP_MENU_LICENSE = "helpMenu.license"; + public static final String HELP_MENU_ABOUT_JPASS = "helpMenu.aboutJpass"; + + public static final String VIEW_WINDOW_TITLE = "viewWindow.title"; + public static final String VIEW_WINDOW_URL = "viewWindow.url"; + public static final String VIEW_WINDOW_USER = "viewWindow.user"; + public static final String VIEW_WINDOW_MODIFIED = "viewWindow.modified"; + public static final String VIEW_WINDOW_CREATED = "viewWindow.created"; + + + public static final String SHOW_MESSAGE_INFORMATION = "showMessage.information"; + public static final String SHOW_MESSAGE_CONFIRMATION = "showMessage.confirmation"; + public static final String SHOW_MESSAGE_WARNING = "showMessage.warning"; + public static final String SHOW_MESSAGE_ERROR = "showMessage.error"; + + public static final String BOTTOM_MENU_ENTRIES_COUNT = "bottomMenu.entriesCount"; + public static final String BOTTOM_MENU_ENTRIES_FOUND= "bottomMenu.entriesFound"; +} diff --git a/src/main/resources/resources/languages/Messages_en_US.properties b/src/main/resources/resources/languages/Messages_en_US.properties new file mode 100644 index 0000000..bb4a8b5 --- /dev/null +++ b/src/main/resources/resources/languages/Messages_en_US.properties @@ -0,0 +1,48 @@ +#Strings for Menu Bar en_US locale +menuBar.fileMenu=File +menuBar.editMenu=Edit +menuBar.toolsMenu=Tools +menuBar.helpMenu=Help + +fileMenu.new=New +fileMenu.openFile=Open File... +fileMenu.save=Save +fileMenu.saveAs=Save As... +fileMenu.exportToXML=Export to XML... +fileMenu.importFromXML=Import from XML... +fileMenu.changePassword="Change Password... +fileMenu.exitMenu=Exit + +changePassword.enterPasswordRequest=Please enter a password. +changePassword.passwordNotModified=Password has not been modified. +changePassword.successfullyModified=Password has been successfully modified.\n\nSave the file now in order to\nget the new password applied. + +editMenu.addEntry=Add Entry... +editMenu.editEntry=Edit Entry... +editMenu.duplicateEntry=Duplicate Entry... +editMenu.deleteEntry=Delete Entry... +editMenu.copyURL=Copy URL +editMenu.copyUserName=Copy User Name +editMenu.copyPassword=Copy Password +editMenu.clearClipboard=Clear Clipboard +editMenu.findEntry=Find Entry + +toolsMenu.generatePassword=Generate Password... + +helpMenu.license=License +helpMenu.aboutJpass=About JPass... + +viewWindow.title=Title +viewWindow.url=URL +viewWindow.user=User +viewWindow.modified=Modified +viewWindow.created=Created + + +showMessage.information=Information +showMessage.confirmation=Confirmation +showMessage.warning=Warning +showMessage.error=Error + +bottomMenu.entriesCount=Entries count +bottomMenu.entriesFound=Entries found \ No newline at end of file diff --git a/src/main/resources/resources/languages/Messages_es_US.properties b/src/main/resources/resources/languages/Messages_es_US.properties new file mode 100644 index 0000000..ecaf8fc --- /dev/null +++ b/src/main/resources/resources/languages/Messages_es_US.properties @@ -0,0 +1,47 @@ +#Strings for Menu Bar es_US locale +menuBar.fileMenu=Archivo +menuBar.editMenu=Editar +menuBar.toolsMenu=Herramientas +menuBar.helpMenu=Ayuda + +fileMenu.new=Nuevo +fileMenu.openFile=Abrir Archivo... +fileMenu.save=Guardar +fileMenu.saveAs=Guardar Como... +fileMenu.exportToXML=Exportar a XML... +fileMenu.importFromXML=Importar desde XML... +fileMenu.changePassword=Cambiar Contraseña... +fileMenu.exitMenu=Salir + +changePassword.enterPasswordRequest=Por favor, introduce una contraseña. +changePassword.passwordNotModified=La contraseña no ha sido modificada. +changePassword.successfullyModified=La contraseña ha sido modificada exitosamente.\n\nGuarda el archivo ahora para asegurarse que la nueva contraseña fue aplicada. + +editMenu.addEntry=Agregar Entrada... +editMenu.editEntry=Editar Entrada... +editMenu.duplicateEntry=Duplicar Entrada... +editMenu.deleteEntry=Remover Entrada... +editMenu.copyURL=Copiar URL +editMenu.copyUserName=Copiar Nombre de Usuario +editMenu.copyPassword=Copiar Contraseña +editMenu.clearClipboard=Limpiar Portapapeles +editMenu.findEntry=Buscar Entrada + +toolsMenu.generatePassword=Generar Contraseña... + +helpMenu.license=Licencia +helpMenu.aboutJpass=Acerca de JPass... + +viewWindow.title=Nombre +viewWindow.url=URL +viewWindow.user=Usuario +viewWindow.modified=Modificado +viewWindow.created=Creado + +showMessage.information=Información +showMessage.confirmation=Confirmación +showMessage.warning=Advertencia +showMessage.error=Error + +bottomMenu.entriesCount=Numero de entradas +bottomMenu.entriesFound=Entradas encontradas \ No newline at end of file