diff --git a/ui/src/main/java/org/adoptopenjdk/jitwatch/ui/main/JITWatchUI.java b/ui/src/main/java/org/adoptopenjdk/jitwatch/ui/main/JITWatchUI.java index 276efb71..08eb8e12 100644 --- a/ui/src/main/java/org/adoptopenjdk/jitwatch/ui/main/JITWatchUI.java +++ b/ui/src/main/java/org/adoptopenjdk/jitwatch/ui/main/JITWatchUI.java @@ -20,6 +20,8 @@ import java.text.ParseException; import java.util.ArrayList; import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; import org.adoptopenjdk.jitwatch.compilation.codecache.CodeCacheEventWalker; import org.adoptopenjdk.jitwatch.compilation.codecache.CodeCacheWalkerResult; @@ -474,7 +476,7 @@ private void stopParsing() comboParser.getSelectionModel().select(ParserType.fromString(parserProperty)); - Button btnChooseWatchFile = new Button("Open Log"); + Button btnChooseWatchFile = UserInterfaceUtil.createButton("OPEN_LOG"); btnChooseWatchFile.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) @@ -484,7 +486,8 @@ private void stopParsing() } }); - btnStart = new Button("Start"); + btnStart = UserInterfaceUtil.createButton("START"); + btnStart.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) @@ -514,7 +517,7 @@ private void stopParsing() } }); - btnStop = new Button("Stop"); + btnStop = UserInterfaceUtil.createButton("STOP"); btnStop.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) @@ -523,7 +526,7 @@ private void stopParsing() } }); - btnConfigure = new Button("Config"); + btnConfigure = UserInterfaceUtil.createButton("CONFIG"); btnConfigure.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) @@ -532,7 +535,7 @@ private void stopParsing() } }); - btnTimeLine = new Button("Timeline"); + btnTimeLine = UserInterfaceUtil.createButton("TIMELINE"); btnTimeLine.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) @@ -545,7 +548,7 @@ private void stopParsing() } }); - btnHisto = new Button("Histo"); + btnHisto = UserInterfaceUtil.createButton("HISTO"); btnHisto.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) @@ -558,7 +561,7 @@ private void stopParsing() } }); - btnTopList = new Button("TopList"); + btnTopList = UserInterfaceUtil.createButton("TOPLIST"); btnTopList.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) @@ -571,7 +574,7 @@ private void stopParsing() } }); - btnCodeCacheTimeline = new Button("Cache"); + btnCodeCacheTimeline = UserInterfaceUtil.createButton("CACHE"); btnCodeCacheTimeline.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) @@ -584,7 +587,7 @@ private void stopParsing() } }); - btnNMethods = new Button("NMethods"); + btnNMethods = UserInterfaceUtil.createButton("NMETHODS"); btnNMethods.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) @@ -600,7 +603,7 @@ private void stopParsing() } }); - btnCompilerThreads = new Button("Threads"); + btnCompilerThreads = UserInterfaceUtil.createButton("THREADS"); btnCompilerThreads.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) @@ -616,7 +619,7 @@ private void stopParsing() } }); - btnTriView = new Button("TriView"); + btnTriView = UserInterfaceUtil.createButton("TRIVIEW"); btnTriView.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) @@ -630,7 +633,7 @@ private void stopParsing() } }); - btnReportSuggestions = new Button("Suggest"); + btnReportSuggestions = UserInterfaceUtil.createButton("SUGGEST"); btnReportSuggestions.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) @@ -644,7 +647,7 @@ private void stopParsing() } }); - btnReportEliminatedAllocations = new Button("-Allocs"); + btnReportEliminatedAllocations = UserInterfaceUtil.createButton("ELIM_ALLOCS"); btnReportEliminatedAllocations.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) @@ -658,7 +661,7 @@ private void stopParsing() } }); - btnReportOptimisedLocks = new Button("-Locks"); + btnReportOptimisedLocks = UserInterfaceUtil.createButton("ELIM_LOCKS"); btnReportOptimisedLocks.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) @@ -672,7 +675,7 @@ private void stopParsing() } }); - btnSandbox = new Button("Sandbox"); + btnSandbox = UserInterfaceUtil.createButton("SANDBOX"); btnSandbox.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) diff --git a/ui/src/main/java/org/adoptopenjdk/jitwatch/util/UserInterfaceUtil.java b/ui/src/main/java/org/adoptopenjdk/jitwatch/util/UserInterfaceUtil.java index 1c702421..c2f1b9e7 100644 --- a/ui/src/main/java/org/adoptopenjdk/jitwatch/util/UserInterfaceUtil.java +++ b/ui/src/main/java/org/adoptopenjdk/jitwatch/util/UserInterfaceUtil.java @@ -12,7 +12,10 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; +import java.util.Locale; +import java.util.ResourceBundle; +import javafx.scene.control.Tooltip; import org.adoptopenjdk.jitwatch.model.bytecode.BCAnnotationType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,6 +35,8 @@ public final class UserInterfaceUtil { private static final Logger logger = LoggerFactory.getLogger(UserInterfaceUtil.class); + public static final ResourceBundle LANG = ResourceBundle.getBundle("i18n.lang", Locale.getDefault()); + // https://www.iconfinder.com/icons/173960/tick_icon#size=16 public static final Image IMAGE_TICK; @@ -40,7 +45,7 @@ public final class UserInterfaceUtil public static final String FONT_MONOSPACE_FAMILY; public static final String FONT_MONOSPACE_SIZE; public static final boolean ADD_CLOSE_DECORATION; // for fullscreen JavaFX - // systems + // systems private UserInterfaceUtil() { @@ -56,6 +61,21 @@ private UserInterfaceUtil() ADD_CLOSE_DECORATION = Boolean.getBoolean("addCloseDecoration"); } + public static Button createButton(String langKey) + { + Button button = new Button(LANG.getString(langKey)); + + String tooltipKey = langKey + "_tt"; + + if (LANG.containsKey(tooltipKey)) + { + String toolTip = LANG.getString(tooltipKey); + button.setTooltip(new Tooltip(toolTip)); + } + + return button; + } + private static Image loadResource(String path) { InputStream inputStream = UserInterfaceUtil.class.getResourceAsStream(path); @@ -86,8 +106,7 @@ public static Button getSnapshotButton(final Scene scene, final String filenameP buttonSnapShot.setOnAction(new EventHandler() { - @Override - public void handle(ActionEvent e) + @Override public void handle(ActionEvent e) { takeSnapShot(scene, filenamePrefix); } @@ -118,11 +137,8 @@ private static void takeSnapShot(Scene scene, String filenamePrefix) Method methodFromFXImage = classSwingFXUtils.getMethod("fromFXImage", new Class[] { javafx.scene.image.Image.class, java.awt.image.BufferedImage.class }); - methodWrite.invoke(null, - new Object[] { - methodFromFXImage.invoke(null, new Object[] { imageSnap, null }), - "png", - new File(snapshotFilename) }); + methodWrite.invoke(null, new Object[] { methodFromFXImage.invoke(null, new Object[] { imageSnap, null }), "png", + new File(snapshotFilename) }); } catch (Throwable t) { diff --git a/ui/src/main/resources/i18n/lang.properties b/ui/src/main/resources/i18n/lang.properties new file mode 100644 index 00000000..852b2986 --- /dev/null +++ b/ui/src/main/resources/i18n/lang.properties @@ -0,0 +1,30 @@ +SANDBOX=Sandbox +SANDBOX_tt=Experiment with JIT behaviour +OPEN_LOG=Open Log +OPEN_LOG_tt=Select LogCompilation file +START=Start +START_tt=Start Processing +STOP=Stop +STOP_tt=Stop Processing +CONFIG=Config +CONFIG_tt=Configure JITWatch +TIMELINE=Timeline +TIMELINE_tt=Timeline of compilation events +HISTO=Histo +HISTO_tt=Histogram of events +CACHE=Cache +CACHE_tt=Code cache usage +NMETHODS=NMethods +NMETHODS_tt=NMethod layout in the code cache +TOPLIST=Toplist +TOPLIST_tt=Compilation activity toplists +THREADS=Threads +THREADS_tt=Compiler thread activity +TRIVIEW=TriView +TRIVIEW_tt=Show source, bytecode, and assembly +SUGGEST=Suggest +SUGGEST_tt=JITWatch suggestions +ELIM_ALLOCS=-Allocs +ELIM_ALLOCS_tt=Eliminated heap allocations +ELIM_LOCKS=-Locks +ELIM_LOCKS_tt=Eliminated Locks \ No newline at end of file diff --git a/ui/src/main/resources/i18n/lang_cn.properties b/ui/src/main/resources/i18n/lang_cn.properties new file mode 100644 index 00000000..43f2cdfe --- /dev/null +++ b/ui/src/main/resources/i18n/lang_cn.properties @@ -0,0 +1 @@ +START=开始 \ No newline at end of file diff --git a/ui/src/main/resources/i18n/lang_de.properties b/ui/src/main/resources/i18n/lang_de.properties new file mode 100644 index 00000000..35ce3677 --- /dev/null +++ b/ui/src/main/resources/i18n/lang_de.properties @@ -0,0 +1 @@ +START=Start \ No newline at end of file diff --git a/ui/src/main/resources/i18n/lang_pl.properties b/ui/src/main/resources/i18n/lang_pl.properties new file mode 100644 index 00000000..b490b02b --- /dev/null +++ b/ui/src/main/resources/i18n/lang_pl.properties @@ -0,0 +1 @@ +START=Początek \ No newline at end of file