Skip to content

Commit

Permalink
Issue #22: add first l10n keys.
Browse files Browse the repository at this point in the history
  • Loading branch information
ottlinger committed Jan 21, 2016
1 parent 77a13ec commit 32de15c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 33 deletions.
6 changes: 1 addition & 5 deletions src/main/java/de/aikiit/spamprotector/AntiSpamApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@
* User: hirsch Date: Apr 10, 2003 Time: 1:24:52 PM
*/
public class AntiSpamApplet extends Applet {
/**
* Preferred size of the complete application window.
*/
private static final Dimension APP_DIMENSION = new Dimension(800, 300);

/**
* Loads UI for this applet.
*/
public final void init() {
add(new GUI(true));
setSize(APP_DIMENSION);
setSize(new Dimension(800, 300));
}
}
15 changes: 3 additions & 12 deletions src/main/java/de/aikiit/spamprotector/AntiSpamApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
*/

package de.aikiit.spamprotector;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import javax.swing.*;
import java.awt.*;

import static de.aikiit.spamprotector.util.LocalizationHelper.getBundleString;
/**
* Application starter class.
*
Expand All @@ -33,15 +33,6 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
final class AntiSpamApplication {

/** Application title to use in Swing window. */
private static final String APP_TITLE = "SpamProtector - "
+ "der einfachste Schutz gegen Spider-Spam und RegEx-Mailadressenscanner";

/**
* Preferred size of the complete application window.
*/
private static final Dimension APP_DIMENSION = new Dimension(800, 300);

/**
* Helper that starts and initializes the application itself.
*/
Expand All @@ -50,9 +41,9 @@ private static void initApplication() {
() -> {
JFrame frame = new JFrame();
GUI g = new GUI(false);
frame.setTitle(APP_TITLE);
frame.setTitle(getBundleString("spamschutz.main.title"));
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(APP_DIMENSION);
frame.setSize(new Dimension(800, 300));
frame.add(g);
frame.setVisible(true);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/aikiit/spamprotector/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class GUI extends JPanel {
* the application is started as an applet or standalone.
*
* @param isApplet Defines whether the application is started as standalone
* <code>false</code> or applet <code>true</code>.
* {@code false} or applet {@code true}.
*/
GUI(final boolean isApplet) {
SwingUtilities.invokeLater(
Expand All @@ -54,7 +54,7 @@ class GUI extends JPanel {
* application is started.
*
* @param isApplet Defines whether the application is started as standalone
* <code>false</code> or applet <code>true</code>.
* {@code false} or applet {@code true}.
*/
private void init(final boolean isApplet) {
final Calendar calendar = Calendar.getInstance();
Expand Down
7 changes: 5 additions & 2 deletions src/main/resources/spamprotector.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# for testing
fotorenamer.test.param={0} und dann folgt noch die {1}
spamschutz.test.param={0} und dann folgt noch die {1}

# AntiSpamApplication.java
spamschutz.main.title=SpamProtector - der einfachste Schutz gegen Spider-Spam und RegEx-Mailadressenscanner

# ProgressBar.java
fotorenamer.ui.progress=Fortschritt
Expand Down Expand Up @@ -52,7 +55,7 @@ fotorenamer.ui.about=bildbearbeiter - fotorenamer\n\nVersion: {0}\n\nAutor: P.Ot
# RemoveExifPrefixRenamer.java

# Test Umlauts
fotorenamer.test.umlauts=\u00df\u00e4\u00fc
spamschutz.test.umlauts=\u00df\u00e4\u00fc

# FIXME: problems with German Umlauts, http://www.utf8-zeichentabelle.de/unicode-utf8-table.pl
# szett = \u00df
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,14 @@
public class LocalizationHelperTest {

/**
* Retrieve a plain i18n-value.
*/
@Test
public final void checkValueRetrievingFromBundle() {
assertEquals("Fortschritt", getBundleString("fotorenamer.ui.progress"));
}

/**
* Retrieve a i18n-value with parameters set.
* Retrieve a i18n-value with parameters.
*/
@Test
public final void checkParametrizedValueExtraction() {
assertEquals("Erfolg und dann folgt noch die 7", getParameterizedBundleString("fotorenamer.test.param",
assertEquals("Erfolg und dann folgt noch die 7", getParameterizedBundleString("spamschutz.test.param",
"Erfolg", 7));
// ignore warning, we want to test what happens here! An empty String or null changes the output.
assertEquals("{0} und dann folgt noch die {1}", getParameterizedBundleString("fotorenamer.test.param",
assertEquals("{0} und dann folgt noch die {1}", getParameterizedBundleString("spamschutz.test.param",
new Object[]{}));
}

Expand Down Expand Up @@ -78,6 +70,6 @@ public final void setLocaleViaSystemProperties() {

@Test
public final void umlautEncodingWorksCorrectly() {
assertEquals("ßäü", getBundleString("fotorenamer.test.umlauts"));
assertEquals("ßäü", getBundleString("spamschutz.test.umlauts"));
}
}

0 comments on commit 32de15c

Please sign in to comment.