Skip to content

Commit

Permalink
Check available help languages when opening specific help page (JabRe…
Browse files Browse the repository at this point in the history
…f#2005)

If help lang not available, use English. Fix for JabRef#1937.
  • Loading branch information
Siedlerchr authored and zesaro committed Oct 27, 2016
1 parent b863a84 commit 02ddcf7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- Fixed InvalidBackgroundColor flickering with Ctrl-s and File > Save database
- Fixed loop when pulling changes (shared database) when current selected field has changed
- Fixed [#1958](https://github.com/JabRef/jabref/issues/1958): Verbatim fields are no longer checked for HTML encoded characters by integrity checks
- Fixed [#1937](https://github.com/JabRef/jabref/issues/1937): If no help page for the current chosen language exists, the english help page will be shown

### Removed
- The non-supported feature of being able to define file directories for any extension is removed. Still, it should work for older databases using the legacy `ps` and `pdf` fields, although we strongly encourage using the `file` field.
Expand Down
24 changes: 22 additions & 2 deletions src/main/java/net/sf/jabref/gui/help/HelpAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.swing.Action;
import javax.swing.Icon;
Expand All @@ -27,6 +31,12 @@
*/
public class HelpAction extends MnemonicAwareAction {

/**
* New languages of the help have to be added here
*/
private static final Set<String> avaiableLangFiles = Stream.of("en", "de", "fr", "in", "ja")
.collect(Collectors.toCollection(HashSet::new));

private HelpFile helpPage;


Expand Down Expand Up @@ -67,6 +77,7 @@ public JLabel getHelpLabel(String labelText) {
helpLabel.setForeground(Color.BLUE);
helpLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
helpLabel.addMouseListener(new MouseAdapter() {

@Override
public void mouseClicked(MouseEvent e) {
openHelpPage();
Expand All @@ -85,7 +96,16 @@ public void actionPerformed(ActionEvent e) {
}

private void openHelpPage() {
String url = "https://help.jabref.org/" + Globals.prefs.get(JabRefPreferences.LANGUAGE) + "/" + helpPage.getPageName();
JabRefDesktop.openBrowserShowPopup(url);
String lang = Globals.prefs.get(JabRefPreferences.LANGUAGE);
StringBuilder sb = new StringBuilder("https://help.jabref.org/");

if (avaiableLangFiles.contains(lang)) {
sb.append(lang);
sb.append("/");
} else {
sb.append("en/");
}
sb.append(helpPage.getPageName());
JabRefDesktop.openBrowserShowPopup(sb.toString());
}
}

0 comments on commit 02ddcf7

Please sign in to comment.