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

Check avaiable help lanugages when opening specific help page #2005

Merged
merged 4 commits into from
Sep 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}