Commit e00c5385 by Tobias

added support for internationalization

1 parent 6ae6c95b
......@@ -10,6 +10,14 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/resources/i18n</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......
package org.stegosuite.ui.gui;
import java.util.Arrays;
import java.util.ResourceBundle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
......@@ -44,10 +45,11 @@ public class AnalyzeUi {
radioButtonNeighbourhoodHist, radioButtonDifferenceImageHist, radioButtonColorTableVisualization,
radioButtonUnreferencedColor;
private Chart currentChart;
private final ResourceBundle L = ResourceBundle.getBundle("Messages");
public AnalyzeUi(TabFolder tabFolder, GuiComponents myComponents) {
tabItem = new TabItem(tabFolder, SWT.NONE);
tabItem.setText("Analyze");
tabItem.setText(L.getString("analyze_tab"));
Composite c1 = new Composite(tabFolder, SWT.NONE);
c1.setLayout(new FillLayout());
......@@ -79,7 +81,7 @@ public class AnalyzeUi {
radioButtonUnreferencedColor = new Button(g, SWT.RADIO);
radioButtonUnreferencedColor.setText("Check for unreferenced colors");
analyzeButton = myComponents.createMainButton(compositeControls, "Analyze");
analyzeButton = myComponents.createMainButton(compositeControls, L.getString("analzye_button"));
tabItem.addListener(SWT.Selection, event -> {
if (label != null && !label.isDisposed() && label.getImage() != null) {
......@@ -146,7 +148,7 @@ public class AnalyzeUi {
/**
* Loads an image from the given path, displays it and displays the according options.
*
*
* @param image The image to load
*/
void loadImage(ImageFormat image) {
......
......@@ -2,6 +2,7 @@ package org.stegosuite.ui.gui;
import java.io.File;
import java.util.Iterator;
import java.util.ResourceBundle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
......@@ -56,11 +57,12 @@ public class EmbedUi {
private ProgressBar progressBar;
private Text pathText;
private static final Logger LOG = LoggerFactory.getLogger(EmbedUi.class);
private final ResourceBundle L = ResourceBundle.getBundle("Messages");
public EmbedUi(TabFolder tabFolder, GuiComponents components) {
myComponents = components;
TabItem tabItem = myComponents.createTabItem(tabFolder, "Embed"); // *
TabItem tabItem = myComponents.createTabItem(tabFolder, L.getString("embed_tab")); // *
Composite c1 = (Composite) tabItem.getControl();
Composite compositeControls = myComponents.createControlsComposite(c1);
......@@ -72,7 +74,7 @@ public class EmbedUi {
pathText = (Text) compositeControls.getChildren()[1]; // *
Text keyText = ((Text) g.getChildren()[0]);
actionButton = myComponents.createMainButton(compositeControls, "Embed"); // *
actionButton = myComponents.createMainButton(compositeControls, L.getString("embed_button")); // *
GridData gd = new GridData();
gd.widthHint = compositeControls.getChildren()[2].computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
......@@ -88,7 +90,8 @@ public class EmbedUi {
if (label.getImage() != null) {
label.setImage(imageContainer.scaleImage());
compositeImage.layout(true, true);
Gui.setStatusBarMsg("Capacity: " + ImageUtils.formatSize(embedding.getCapacity()));
Gui.setStatusBarMsg(
L.getString("statusbar_capacity") + ": " + ImageUtils.formatSize(embedding.getCapacity()));
}
});
......
......@@ -4,6 +4,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ResourceBundle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
......@@ -57,10 +58,11 @@ public class ExtractUi {
private ProgressBar progressBar;
private StyledText styledText;
private static final Logger LOG = LoggerFactory.getLogger(ExtractUi.class);
private final ResourceBundle L = ResourceBundle.getBundle("Messages");
public ExtractUi(TabFolder tabFolder, GuiComponents components) {
myComponents = components;
TabItem tabItem = myComponents.createTabItem(tabFolder, "Extract"); // *
TabItem tabItem = myComponents.createTabItem(tabFolder, L.getString("extract_tab")); // *
Composite c1 = (Composite) tabItem.getControl();
Composite compositeControls = myComponents.createControlsComposite(c1);
......@@ -68,12 +70,12 @@ public class ExtractUi {
g = myComponents.createParametersGroup(compositeControls);
styledText = (StyledText) compositeControls.getChildren()[0];
styledText.setText(" ");
styledText.setToolTipText("Extracted text message");
styledText.setToolTipText(L.getString("message_text_tooltip_extract"));
styledText.setEditable(false);
Text keyText = ((Text) g.getChildren()[0]);
actionButton = myComponents.createMainButton(compositeControls, "Extract");
actionButton = myComponents.createMainButton(compositeControls, L.getString("extract_button"));
compositeImage = myComponents.createImageComposite(c1);
label = new Label(compositeImage, SWT.NONE);
......
package org.stegosuite.ui.gui;
import java.io.File;
import java.util.ResourceBundle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.DND;
......@@ -39,6 +40,7 @@ public class Gui {
private TabFolder tabFolder;
private static Label statusBar;
private final ResourceBundle L = ResourceBundle.getBundle("Messages");
public Gui() {
display = new Display();
......@@ -97,7 +99,7 @@ public class Gui {
/**
* Loads a gif- or bmp-image and displays it on all 3 tabs.
*
*
* @param path absolute file-path of the image
*/
private void loadImages(final String path) {
......@@ -123,7 +125,7 @@ public class Gui {
/**
* Sets the message of the global status bar.
*
*
* @param s String which gets displayed.
*/
static void setStatusBarMsg(final String s) {
......@@ -132,7 +134,7 @@ public class Gui {
private void showStartScreen() {
final Label label = new Label(shell, SWT.SHADOW_NONE);
label.setText("Please load an image to get started.");
label.setText(L.getString("start_text"));
// increase font size
final FontData[] fontData = label.getFont().getFontData();
......@@ -160,7 +162,7 @@ public class Gui {
if (tabFolder.getSelectionIndex() == 2 && menuBar.getItem(0).getMenu().getItemCount() == 1) {
MenuItem saveItem = new MenuItem(menuBar.getItem(0).getMenu(), SWT.PUSH, 1);
saveItem.setText("&Save diagram...");
saveItem.setText(L.getString("save_diagram_menu"));
saveItem.addListener(SWT.Selection, event2 -> {
FileDialog dlg = new FileDialog(shell, SWT.SAVE);
final String[] FILTER_EXTS = { "*.png" };
......
package org.stegosuite.ui.gui;
import java.util.ResourceBundle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Font;
......@@ -33,6 +35,7 @@ public class GuiComponents {
EmbedUi embedUi;
ExtractUi extractUi;
AnalyzeUi analyzeUi;
private final ResourceBundle L = ResourceBundle.getBundle("Messages");
Shell createShell(Display display) {
Shell shell = new Shell(display);
......@@ -59,13 +62,13 @@ public class GuiComponents {
Menu createMenuBar(Shell shell) {
Menu menuBar = new Menu(shell, SWT.BAR);
MenuItem cascadeFileMenu = new MenuItem(menuBar, SWT.CASCADE);
cascadeFileMenu.setText("&File");
cascadeFileMenu.setText(L.getString("file_menu"));
Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
cascadeFileMenu.setMenu(fileMenu);
MenuItem loadItem = new MenuItem(fileMenu, SWT.PUSH, LOAD_MENU_ITEM);
loadItem.setText("&Load image...");
loadItem.setText(L.getString("load_image_menu"));
shell.setMenuBar(menuBar);
return menuBar;
......@@ -99,8 +102,8 @@ public class GuiComponents {
StyledText text = new StyledText(compositeControls, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP | SWT.BORDER);
text.setAlwaysShowScrollBars(false);
text.setText("My secret message.");
text.setToolTipText("Secret message, which gets embedded into the image");
text.setText(L.getString("message_text"));
text.setToolTipText(L.getString("message_text_tooltip"));
/*
* text.addListener(SWT.MouseDown, event -> { text.setText(""); });
*/
......@@ -115,14 +118,14 @@ public class GuiComponents {
void createFileEmbedding(Composite parent) {
Text t2 = new Text(parent, SWT.SINGLE | SWT.BORDER);
t2.setText("File to be embedded.");
t2.setText(L.getString("file_text"));
t2.setEnabled(false);
t2.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
Button b = new Button(parent, SWT.PUSH);
b.setLayoutData(new GridData(SWT.RIGHT, SWT.BEGINNING, false, false));
b.setToolTipText("Embed a file into the image");
b.setText("Browse...");
b.setToolTipText(L.getString("file_button_tooltip"));
b.setText(L.getString("file_button"));
}
Composite createParametersGroup(Composite parent) {
......@@ -134,7 +137,7 @@ public class GuiComponents {
data.horizontalSpan = 2;
g.setLayoutData(data);
g.setText("Secret key");
g.setText(L.getString("key_group"));
g.setLayout(mGridLayoutGroup);
// Label labelKey = new Label(g, SWT.LEFT);
......@@ -142,8 +145,8 @@ public class GuiComponents {
// labelKey.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false));
Text t2 = new Text(g, SWT.SINGLE | SWT.BORDER);
t2.setText("My secret key.");
t2.setToolTipText("Secret key used for hiding and encrypting the content");
t2.setText(L.getString("key_text"));
t2.setToolTipText(L.getString("key_text_tooltip"));
t2.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
t2.addListener(SWT.MouseDown, event -> {
t2.selectAll();
......
start_text = Please load an image to get started.
file_menu = &File
load_image_menu = &Load image...
save_diagram_menu = &Save diagram...
save_diagram2_menu = &Save diagram as *_analyzed.png
embed_tab = Embed
extract_tab = Extract
analyze_tab = Analyze
embed_button = Embed
extract_button = Extract
analyze_button = Analyze
message_text = My secret message.
message_text_tooltip = Secret message, which gets embedded into the image
message_text_tooltip_extract = Extracted text message
file_text = File to be embedded
file_button = Browse...
file_button_tooltip = Embed a file into the image
key_group = Secret key
key_text = My secret key.
key_text_tooltip = Secret key used for hiding and encrypting the content
statusbar_capacity = Capacity
start_text = Bitte lade ein Bild um loszulegen.
file_menu = &Datei
load_image_menu = &Bild laden...
save_diagram_menu = &Diagramm Speichern...
save_diagram2_menu = &Diagramm als *_analyzed.png speichern
embed_tab = Einbetten
extract_tab = Extrahieren
analyze_tab = Analysieren
embed_button = Einbetten
extract_button = Extrahieren
analyze_button = Analysieren
message_text = Meine geheime Nachricht.
message_text_tooltip = Geheime Nachricht, die in das Bild eingebettet wird
message_text_tooltip_extract = Extrahierte Nachricht
file_text = Einzubettende Datei
file_button = Durchsuchen...
file_button_tooltip = Bettet eine Datei in das Bild ein.
key_group = Geheimer Schlüssel
key_text = Mein geheimer Schlüssel.
key_text_tooltip = Geheimer Schlüssel, zum Verstecken und Verschlüsseln des Inhalts
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!