Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jpass- Adds user-selected language feature #32

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

edimoral
Copy link
Contributor

@edimoral edimoral commented Mar 10, 2024

This PR introduces:

  • Updates GUI when user selects a language
  • Stores the language selected in jpass.properties file
  • Sets JFileChooser CANCEL button based on language selected
  • Updates README.md file
  • Adds UTs to increase code coverage

@@ -215,7 +258,7 @@ private JPassFrame(String fileName, Locale locale) {

setJMenuBar(this.jpassMenuBar);
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
setSize(450, 400);
setSize(490, 400);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaborbata Increases width to allow long string for some JMenu to be displayed. Let me know what you think about this.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, however it can be a bit wider (plese check with other languages).

@@ -1,6 +1,7 @@
menuBar.fileMenu=Fájl
menuBar.editMenu=Szerkesztés
menuBar.toolsMenu=Eszközök
menuBar.settingsMenu=Settings
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaborbata can you also please help to translate these to Hungarian language?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it is called Beállítások in Hungarian

@@ -87,3 +90,9 @@ panel.save=Salva
panel.open=Apri
panel.saveModifiedQuestionMessage=Il file attuale è stato modificato.\nVuoi salvare le modifiche prima della chiusura?
panel.unencryptedDataWarningMessage=Nota che tutti i dati verranno archiviati non crittografati.\nAssicurati di conservare il file esportato in un luogo sicuro.

language.languageChanged=Language has changed successfully.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bovirus If you have some time, can you please suggest the correct translation to Italian for these strings added?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

language.languageChanged=Impostazione lingua completata.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the input, @bovirus . Can you also please check the other new strings added to this file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edimoral

Where can I get the latest Italian language (i see until line 89)?

@@ -98,6 +101,20 @@ public String get(String key, String defaultValue) {
return properties.getProperty(key, defaultValue);
}

public void set(String key, String value) {
properties.setProperty(key, value);
saveProperties();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the feature to stores the user-selected language hence next time JPass is opened up will be using the language selected. Let me know what you think about this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me is ok.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Unfortunately, comments are not saved.

SUPPORTED_LANGUAGES.forEach((key, value) -> {
JMenuItem language = new JMenuItem(localizedMessages.getString(key));
if (Objects.equals(getCurrentLanguage(), value)) {
language.setIcon(getIcon("check_mark"));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added two new icons. Let me know if these ones are ok or what should be the process to add new ones.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me is ok.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @edimoral, could you please use symbolic icons from https://github.com/elementary/icons ?

Also, please make sure every icon has two versions in the resources:

  • one without a postfix e.g. world.svg with fill color fill='#666' (this is for the light theme)
  • one with the _dark postfix e.g. world_dark.svg with fill color fill='#999' (this is for dark theme)

@gaborbata
Copy link
Owner

Thanks for your changes, I'll review them in the following weeks (depending on job activities).

@@ -2,6 +2,7 @@
menuBar.fileMenu=File
menuBar.editMenu=Modifica
menuBar.toolsMenu=Strumenti
menuBar.settingsMenu=Settings
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bovirus here

@@ -35,6 +36,8 @@ editMenu.findEntry=Trova elemento

toolsMenu.generatePassword=Genera password...

settingsMenu.language=Language
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bovirus here

@@ -87,3 +90,9 @@ panel.save=Salva
panel.open=Apri
panel.saveModifiedQuestionMessage=Il file attuale è stato modificato.\nVuoi salvare le modifiche prima della chiusura?
panel.unencryptedDataWarningMessage=Nota che tutti i dati verranno archiviati non crittografati.\nAssicurati di conservare il file esportato in un luogo sicuro.

language.languageChanged=Language has changed successfully.
language.en.us=Inglese
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And those from L:95 to L:98
@bovirus here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edimoral

I didn't see this line (n. 95) in

src/main/resources/resources/languages/languages_it_IT.properties

The file has 89 lines.

@@ -232,8 +275,13 @@ public static JPassFrame getInstance() {

public static synchronized JPassFrame getInstance(String fileName) {
if (instance == null) {
String languageTag = Configuration.getInstance().get("language.languageSetting", "en-US");
instance = new JPassFrame(fileName, Locale.forLanguageTag(languageTag));
String languageTag = Configuration.getInstance().get(LANGUAGE_LANGUAGE_SETTING, null);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you simply use Configuration.getInstance().get(LANGUAGE_LANGUAGE_SETTING, "en-US") here?

@@ -87,3 +90,9 @@ panel.save=Save
panel.open=Open
panel.saveModifiedQuestionMessage=The current file has been modified.\nDo you want to save the changes before closing?
panel.unencryptedDataWarningMessage=Please note that all data will be stored unencrypted.\nMake sure you keep the exported file in a secure location.

language.languageChanged=Language has changed successfully.
language.en.us=English
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is a good idea to store language names in language resources. Every time a new translation in introduced, then all the resources need to be updated. Maybe it would be better to hard-code them in the supported languages map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants