Skip to content

Conversation

@Ramona2021
Copy link

added language en, de, fr and public possibilty to switch

matchesLabel.setText(matchCount + " matches");
}
pageLabel.setText(getTranslation("Page", (item.getPageNumber() + 1)));
matchesLabel.setText(getTranslation("Matches", item.getItems().size()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This does not handle the same situations as the original code. I explicitly want to write "1 match" and "2 matches" (singular, plural).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just saw the resource bundle. I didn't know that this is possible. So you can specify this to use either singular or plural translation? If so then I learned something new today :-)

}
}

public void loadLanguageProperties(String language) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not know any JavaFX controls that explicitly add methods for translating the control. This should happen automatically. The control should pickup the required language bundle based on the language currently used by the JVM. If you need to be able to switch languages at runtime then you need to subclass the control and add the feature there.

…class to enable translations in PDFView and PDFViewSkin
Copy link
Collaborator

@dlemmermann dlemmermann left a comment

Choose a reason for hiding this comment

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

Why is there a "Translation" class. Why can't we simply use the default way of working with Resource Bundles. Blog: https://medium.com/@medcherrou/understanding-resourcebundle-in-java-a-comprehensive-guide-2cb3b49edf03

private Properties languageProperties = new Properties();

public String getTranslation(String languageString, Object ... arguments) {
if(languageProperties.isEmpty()){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use default IntelliJ formatting. I noticed that a space is missing after the "if".

Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is superseded by my remarks regarding the use of a proper ResourceBundle.

loadLanguageProperties();
}
String message = languageString;
if (languageProperties != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

These two if-statements can be merged.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is superseded by my remarks regarding the use of a proper ResourceBundle.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants