From fa70ef030881a41a504f13345c22ddc74048a3d4 Mon Sep 17 00:00:00 2001 From: WiredSpast Date: Sat, 6 Aug 2022 03:12:47 +0200 Subject: [PATCH] Add packet logger internationalization --- .../uilogger/UiLoggerController.java | 25 +++--- .../uilogger/UiLoggerCreator.java | 3 +- .../uilogger/UiLogger.fxml | 78 +++++++++---------- .../ui/translations/messages.properties | 65 +++++++++++++++- .../ui/translations/messages_de.properties | 65 +++++++++++++++- .../ui/translations/messages_es.properties | 65 +++++++++++++++- .../ui/translations/messages_fi.properties | 65 +++++++++++++++- .../ui/translations/messages_fr.properties | 65 +++++++++++++++- .../ui/translations/messages_it.properties | 65 +++++++++++++++- .../ui/translations/messages_nl.properties | 62 +++++++++++++++ .../ui/translations/messages_pt.properties | 65 +++++++++++++++- .../ui/translations/messages_tr.properties | 65 +++++++++++++++- 12 files changed, 628 insertions(+), 60 deletions(-) diff --git a/G-Earth/src/main/java/gearth/services/internal_extensions/uilogger/UiLoggerController.java b/G-Earth/src/main/java/gearth/services/internal_extensions/uilogger/UiLoggerController.java index 26b6af0..ff41456 100644 --- a/G-Earth/src/main/java/gearth/services/internal_extensions/uilogger/UiLoggerController.java +++ b/G-Earth/src/main/java/gearth/services/internal_extensions/uilogger/UiLoggerController.java @@ -1,6 +1,7 @@ package gearth.services.internal_extensions.uilogger; import at.favre.lib.bytes.Bytes; + import gearth.GEarth; import gearth.misc.Cacher; import gearth.services.internal_extensions.uilogger.hexdumper.Hexdump; import gearth.services.packet_info.PacketInfo; @@ -219,7 +220,7 @@ public class UiLoggerController implements Initializable { if (chkTimestamp.isSelected()) { - elements.add(new Element(String.format("(timestamp: %d)\n", System.currentTimeMillis()), "timestamp")); + elements.add(new Element(String.format("(%s: %d)\n", GEarth.translation.getString("ext.logger.element.timestamp"), System.currentTimeMillis()), "timestamp")); } boolean packetInfoAvailable = uiLogger.getPacketInfoManager().getPacketInfoList().size() > 0; @@ -256,8 +257,8 @@ public class UiLoggerController implements Initializable { elements.add(new Element("\n", "")); } - if (isBlocked) elements.add(new Element("[Blocked]\n", "blocked")); - else if (isReplaced) elements.add(new Element("[Replaced]\n", "replaced")); + if (isBlocked) elements.add(new Element(String.format("[%s]\n", GEarth.translation.getString("ext.logger.element.blocked")), "blocked")); + else if (isReplaced) elements.add(new Element(String.format("[%s]\n", GEarth.translation.getString("ext.logger.element.replaced")), "replaced")); if (!chkReprNone.isSelected()) { boolean isSkipped = chkSkipBigPackets.isSelected() && (packet.length() > 4000 || (packet.length() > 1000 && chkReprHex.isSelected())); @@ -265,7 +266,7 @@ public class UiLoggerController implements Initializable { Hexdump.hexdump(packet.toBytes()) : (chkReprRawHex.isSelected() ? Bytes.wrap(packet.toBytes()).encodeHex() : packet.toString()); - String type = isIncoming ? "Incoming" : "Outgoing"; + String type = isIncoming ? GEarth.translation.getString("ext.logger.element.direction.incoming") : GEarth.translation.getString("ext.logger.element.direction.outgoing"); if (!chkReprHex.isSelected()) { elements.add(new Element(String.format("%s[", type), type.toLowerCase())); @@ -276,7 +277,7 @@ public class UiLoggerController implements Initializable { } if (isSkipped) { - elements.add(new Element("", "skipped")); + elements.add(new Element(String.format("<%s>", GEarth.translation.getString("ext.logger.element.skipped")), "skipped")); } else elements.add(new Element(packetRepresentation, String.format(chkReprHex.isSelected() ? "%sHex": "%s", type.toLowerCase()))); elements.add(new Element("\n", "")); @@ -343,13 +344,13 @@ public class UiLoggerController implements Initializable { public void updateLoggerInfo() { Platform.runLater(() -> { - lblViewIncoming.setText("View Incoming: " + (chkViewIncoming.isSelected() ? "True" : "False")); - lblViewOutgoing.setText("View Outgoing: " + (chkViewOutgoing.isSelected() ? "True" : "False")); - lblAutoScrolll.setText("Autoscroll: " + (chkAutoscroll.isSelected() ? "True" : "False")); - lblFiltered.setText("Filtered: " + filteredAmount); + lblViewIncoming.setText(String.format("%s: %s", GEarth.translation.getString("ext.logger.menu.view.incoming"), (chkViewIncoming.isSelected() ? "True" : "False"))); + lblViewOutgoing.setText(String.format("%s: %s", GEarth.translation.getString("ext.logger.menu.view.outgoing"), (chkViewOutgoing.isSelected() ? "True" : "False"))); + lblAutoScrolll.setText(String.format("%s: %s", GEarth.translation.getString("ext.logger.menu.view.autoscroll"), (chkAutoscroll.isSelected() ? "True" : "False"))); + lblFiltered.setText(String.format("%s: %d", GEarth.translation.getString("ext.logger.state.filtered"), filteredAmount)); boolean packetInfoAvailable = uiLogger.getPacketInfoManager().getPacketInfoList().size() > 0; - lblPacketInfo.setText("Packet info: " + (packetInfoAvailable ? "True" : "False")); + lblPacketInfo.setText(String.format("%s: %s", GEarth.translation.getString("ext.logger.state.packetinfo"), (packetInfoAvailable ? "True" : "False"))); }); } @@ -389,9 +390,9 @@ public class UiLoggerController implements Initializable { //Set extension filter FileChooser.ExtensionFilter extFilter = - new FileChooser.ExtensionFilter("TXT files (*.txt)", "*.txt"); + new FileChooser.ExtensionFilter(String.format("%s (*.txt)", GEarth.translation.getString("ext.logger.menu.packets.exportall.filetype")), "*.txt"); fileChooser.getExtensionFilters().add(extFilter); - fileChooser.setTitle("Save Packets"); + fileChooser.setTitle(GEarth.translation.getString("ext.logger.menu.packets.exportall.windowtitle")); //Show save file dialog File file = fileChooser.showSaveDialog(stage); diff --git a/G-Earth/src/main/java/gearth/services/internal_extensions/uilogger/UiLoggerCreator.java b/G-Earth/src/main/java/gearth/services/internal_extensions/uilogger/UiLoggerCreator.java index 43f43ce..b21b106 100644 --- a/G-Earth/src/main/java/gearth/services/internal_extensions/uilogger/UiLoggerCreator.java +++ b/G-Earth/src/main/java/gearth/services/internal_extensions/uilogger/UiLoggerCreator.java @@ -1,5 +1,6 @@ package gearth.services.internal_extensions.uilogger; +import gearth.GEarth; import gearth.extensions.InternalExtensionFormCreator; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; @@ -13,7 +14,7 @@ public class UiLoggerCreator extends InternalExtensionFormCreator { public UiLogger createForm(Stage stage) throws Exception { UiLogger uiLogger = new UiLogger(); - FXMLLoader loader = new FXMLLoader(UiLogger.class.getResource("UiLogger.fxml")); + FXMLLoader loader = new FXMLLoader(UiLogger.class.getResource("UiLogger.fxml"), GEarth.translation); Parent root = loader.load(); stage.setTitle("G-Earth | Packet Logger"); diff --git a/G-Earth/src/main/resources/gearth/services/internal_extensions/uilogger/UiLogger.fxml b/G-Earth/src/main/resources/gearth/services/internal_extensions/uilogger/UiLogger.fxml index c257d5e..52d9fc5 100644 --- a/G-Earth/src/main/resources/gearth/services/internal_extensions/uilogger/UiLogger.fxml +++ b/G-Earth/src/main/resources/gearth/services/internal_extensions/uilogger/UiLogger.fxml @@ -8,83 +8,83 @@ - + - - + + - - + + - + - - + + - - + + - + - + - + - + - + - + - + - - - + + + - + - - - + + + - - + + - + - + - - - - + + + + - - + + @@ -94,7 +94,7 @@ -