Add ZH translations for SysTray pop-up menu.

Reduce log spam when SysTray can't open Node UI in browser,
e.g. no browser installed, or no association for URLs.
This commit is contained in:
catbref 2019-07-09 12:40:00 +01:00
parent 0d85a60c54
commit 6942c02700
4 changed files with 20 additions and 17 deletions

View File

@ -7,7 +7,6 @@ import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.SwingWorker;
@ -15,6 +14,7 @@ import javax.swing.SwingWorker;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.qora.controller.Controller;
import org.qora.globalization.Translator;
import org.qora.settings.Settings;
import org.qora.utils.URLViewer;
@ -59,19 +59,19 @@ public class SysTray {
private PopupMenu createPopupMenu() {
PopupMenu menu = new PopupMenu();
MenuItem openUi = new MenuItem("Open UI");
MenuItem openUi = new MenuItem(Translator.INSTANCE.translate("SysTray", "OPEN_NODE_UI"));
openUi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
URLViewer.openWebpage(new URL("http://localhost:" + Settings.getInstance().getUiPort()));
} catch (MalformedURLException e1) {
LOGGER.error(e1.getMessage(),e1);
} catch (Exception e1) {
LOGGER.error("Unable to open node UI in browser");
}
}
});
menu.add(openUi);
MenuItem exit = new MenuItem("Exit");
MenuItem exit = new MenuItem(Translator.INSTANCE.translate("SysTray", "EXIT"));
exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new ClosingWorker().execute();

View File

@ -12,23 +12,18 @@ public class URLViewer {
private static final Logger LOGGER = LogManager.getLogger(URLViewer.class);
public static void openWebpage(URI uri) {
public static void openWebpage(URI uri) throws Exception {
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(uri);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE))
desktop.browse(uri);
}
public static void openWebpage(URL url) {
public static void openWebpage(URL url) throws Exception {
try {
openWebpage(url.toURI());
} catch (URISyntaxException e) {
LOGGER.error(e.getMessage(), e);
LOGGER.error(String.format("Invalid URL: %s", url.toString()));
}
}

View File

@ -1,3 +1,7 @@
# SysTray pop-up menu
OPEN_NODE_UI=Open Node UI
EXIT=Exit
# Nagging about lack of NTP time sync
NTP_NAG_CAPTION=No connections?
NTP_NAG_TEXT=Please enable Windows automatic time synchronization

View File

@ -1,3 +1,7 @@
# SysTray pop-up menu
OPEN_NODE_UI=开启界面
EXIT=退出软件
# Nagging about lack of NTP time sync
NTP_NAG_CAPTION=No connections?
NTP_NAG_TEXT=Please enable Windows automatic time synchronization
NTP_NAG_CAPTION=没有连接上节点?
NTP_NAG_TEXT=请启用Windows自动时间同步。