Skip to content

Commit

Permalink
Merge pull request #41 from xEdziu/v3.0.0-internationalization
Browse files Browse the repository at this point in the history
v3.0.0 internationalization
  • Loading branch information
xEdziu authored Mar 28, 2022
2 parents 90a1376 + a01c371 commit e61fd06
Show file tree
Hide file tree
Showing 14 changed files with 831 additions and 247 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.goral</groupId>
<artifactId>KeepMyPassword-Desktop</artifactId>
<version>2.3.3</version>
<version>3.0.0</version>
<name>KeepMyPassword Desktop</name>
<packaging>jar</packaging>

Expand Down
29 changes: 28 additions & 1 deletion src/main/java/me/goral/keepmypassworddesktop/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import me.goral.keepmypassworddesktop.util.AlertsUtil;
import me.goral.keepmypassworddesktop.util.ConfUtil;

import java.util.Locale;
import java.util.ResourceBundle;

public class MainApp extends Application {

private static Stage guiStage;
Expand All @@ -19,6 +22,30 @@ public static Stage getStage() {
return guiStage;
}

public static Locale loc = setLocale();
public static ResourceBundle lang = setLanguageBundle(loc);

/**
* The function returns a Locale object that is set to the language specified in the configuration file
*
* @return The locale object.
*/
public static Locale setLocale(){
String lang = ConfUtil.getConfigLanguage();
return new Locale(lang);
}

/**
* This function returns a ResourceBundle object that contains the localized strings for the given locale
*
* @param loc The locale of the language you want to use.
* @return The ResourceBundle object.
*/
public static ResourceBundle setLanguageBundle(Locale loc){
return ResourceBundle
.getBundle("language", loc); //NON-NLS
}

@Override
public void start(Stage stage) {

Expand All @@ -34,7 +61,7 @@ public void start(Stage stage) {
MainAppController mainController = loader.getController();
scene.getStylesheets().add(css);
guiStage.initStyle(StageStyle.DECORATED);
guiStage.setTitle("Keep My Password");
guiStage.setTitle(lang.getString("appName"));
guiStage.setResizable(false);
guiStage.getIcons().add(new Image(MainApp.class.getResourceAsStream("/me/goral/keepmypassworddesktop/images/access-32.png")));
guiStage.setWidth(750);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/me/goral/keepmypassworddesktop/MainClass.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package me.goral.keepmypassworddesktop;

import me.goral.keepmypassworddesktop.util.ConfUtil;

public class MainClass {
public static void main(String[] args) {
ConfUtil.setWorkingDirectory();
MainApp.main(args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@

public class LoggedController {

@FXML private Label loggedAsLabel;
@FXML private TableView<PasswordRow> contentTable;
@FXML private TableColumn<PasswordRow, String> idColumn = new TableColumn<>("id");
@FXML private TableColumn<PasswordRow, String> descColumn = new TableColumn<>("Description");
@FXML private TableColumn<PasswordRow, String> loginColumn = new TableColumn<>("Login");
@FXML private TableColumn<PasswordRow, String> pwdColumn = new TableColumn<>("Password");
@FXML private TableColumn<PasswordRow, String> ivColumn = new TableColumn<>("IV");
@FXML private TableColumn<PasswordRow, String> idColumn = new TableColumn<>("id");//NON-NLS
@FXML private TableColumn<PasswordRow, String> descColumn = new TableColumn<>(MainApp.lang.getString("description-table-desc"));
@FXML private TableColumn<PasswordRow, String> loginColumn = new TableColumn<>(MainApp.lang.getString("login-table-desc"));
@FXML private TableColumn<PasswordRow, String> pwdColumn = new TableColumn<>(MainApp.lang.getString("password-table-desc"));
@FXML private TableColumn<PasswordRow, String> ivColumn = new TableColumn<>("IV");//NON-NLS
@FXML private Label unameLabel;
@FXML private Button showBtn;
@FXML private Button addButton;
Expand All @@ -41,7 +42,18 @@ public class LoggedController {
@FXML
private void initialize() {

showBtn.getStyleClass().add("show");
descColumn.setText(MainApp.lang.getString("description-table-desc"));
loginColumn.setText(MainApp.lang.getString("login-table-desc"));
pwdColumn.setText(MainApp.lang.getString("password-table-desc"));

addButton.setText(MainApp.lang.getString("add"));
genPwd.setText(MainApp.lang.getString("generate"));
removeButton.setText(MainApp.lang.getString("remove"));

contentTable.setPlaceholder(new Label(MainApp.lang.getString("no.content.in.table")));
loggedAsLabel.setText(MainApp.lang.getString("logged.as"));

showBtn.getStyleClass().add("show"); //NON-NLS
addButton.setWrapText(true);
removeButton.setWrapText(true);
genPwd.setWrapText(true);
Expand All @@ -68,11 +80,20 @@ private void initialize() {
ivColumn.setCellValueFactory(
p -> new SimpleStringProperty(p.getValue().getIv())
);
idColumn.setVisible(false);
ivColumn.setVisible(false);

idColumn.setResizable(false);
descColumn.setResizable(false);
loginColumn.setResizable(false);
pwdColumn.setResizable(false);
ivColumn.setResizable(false);

idColumn.setReorderable(false);
descColumn.setReorderable(false);
loginColumn.setReorderable(false);
pwdColumn.setReorderable(false);
ivColumn.setReorderable(false);

descColumn.setCellFactory(c -> new TableCell<>() {

Expand All @@ -89,7 +110,7 @@ protected void updateItem(String item, boolean empty) {
setGraphic(null);
} else {
text.setText(item);
text.getStyleClass().add("txt");
text.getStyleClass().add("txt");//NON-NLS
setGraphic(text);
}
}
Expand All @@ -110,7 +131,7 @@ protected void updateItem(String item, boolean empty) {
setGraphic(null);
} else {
text.setText(item);
text.getStyleClass().add("txt");
text.getStyleClass().add("txt");//NON-NLS
setGraphic(text);
}
}
Expand All @@ -130,7 +151,7 @@ protected void updateItem(String item, boolean empty) {
setGraphic(null);
} else {
text.setText(item);
text.getStyleClass().add("txt");
text.getStyleClass().add("txt");//NON-NLS
setGraphic(text);
}
}
Expand All @@ -144,7 +165,7 @@ protected void updateItem(String item, boolean empty) {
PasswordRow rowData = row.getItem();
int id = Integer.parseInt(rowData.getId());
AlertsUtil.showUpdatePasswordDialog(id, rowData.getDesc(),rowData.getLogin(),
rowData.getPwd(), key, rowData.getIv());
rowData.getPwd(), key);
refreshContentTable();
}
});
Expand Down Expand Up @@ -184,18 +205,17 @@ private void onRemoveClick(){
if (DatabaseHandler.deletePassword(id)){
refreshContentTable();
} else {
AlertsUtil.showErrorDialog("Error Alert",
"Sorry. Something went wrong while deleting your password",
"Please report that error to github, so that developer can repair it as soon as possible:\n" +
"https://github.com/xEdziu/KeepMyPassword-Desktop/issues/new/choose");
AlertsUtil.showErrorDialog(MainApp.lang.getString("error.alert"),
MainApp.lang.getString("error-deleting-pwd"),
MainApp.lang.getString("info-send-issue-to-gh"));
}

} catch (SQLException e) {
AlertsUtil.showExceptionStackTraceDialog(e);
}
} else {
AlertsUtil.showInformationDialog("No item selected", "Wait a minute..",
"You haven't selected any item to remove!");
AlertsUtil.showInformationDialog(MainApp.lang.getString("no.item.selected"), MainApp.lang.getString("wait.a.minute.err"),
MainApp.lang.getString("no-select-error"));
}
}

Expand All @@ -208,10 +228,10 @@ private void onRemoveClick(){
private void onShowBtnClick(){
if (!showed){
showBtn.getStyleClass().clear();
showBtn.getStyleClass().addAll("button","hide");
showBtn.getStyleClass().addAll("button","hide");//NON-NLS
} else {
showBtn.getStyleClass().clear();
showBtn.getStyleClass().addAll("button","show");
showBtn.getStyleClass().addAll("button","show");//NON-NLS
}
showed = !showed;
refreshContentTable();
Expand Down Expand Up @@ -275,9 +295,9 @@ private List<PasswordRow> parsePasswordsList(boolean visible) {
IvParameterSpec iv = new IvParameterSpec(Base64.getDecoder().decode(ivEnc));

//decrypt data from database
String descDec = AESUtil.decrypt("AES/CBC/PKCS5Padding", new String(Base64.getDecoder().decode(descEnc)), key, iv);
String loginDec = AESUtil.decrypt("AES/CBC/PKCS5Padding", new String(Base64.getDecoder().decode(loginEnc)), key, iv);
String pwdDec = AESUtil.decrypt("AES/CBC/PKCS5Padding", new String(Base64.getDecoder().decode(pwdEnc)), key, iv);
String descDec = AESUtil.decrypt("AES/CBC/PKCS5Padding", new String(Base64.getDecoder().decode(descEnc)), key, iv);//NON-NLS
String loginDec = AESUtil.decrypt("AES/CBC/PKCS5Padding", new String(Base64.getDecoder().decode(loginEnc)), key, iv);//NON-NLS
String pwdDec = AESUtil.decrypt("AES/CBC/PKCS5Padding", new String(Base64.getDecoder().decode(pwdEnc)), key, iv);//NON-NLS

//add decrypted things to new PasswordRow
PasswordRow pr = new PasswordRow(id, descDec, loginDec, pwdDec, ivEnc, visible);
Expand Down
Loading

0 comments on commit e61fd06

Please sign in to comment.