[Schmitzm-commits] r185 - trunk/src/skrueger/i8n

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jul 3 16:36:08 CEST 2009


Author: alfonx
Date: 2009-07-03 16:36:08 +0200 (Fri, 03 Jul 2009)
New Revision: 185

Modified:
   trunk/src/skrueger/i8n/I8NUtil.java
   trunk/src/skrueger/i8n/Translation.java
Log:
* Un-deprecated the constructor Translation(String);


Modified: trunk/src/skrueger/i8n/I8NUtil.java
===================================================================
--- trunk/src/skrueger/i8n/I8NUtil.java	2009-07-03 13:11:18 UTC (rev 184)
+++ trunk/src/skrueger/i8n/I8NUtil.java	2009-07-03 14:36:08 UTC (rev 185)
@@ -20,7 +20,36 @@
 	}
 
 	/**
+	 * Creates a {@link Translation}<br/>
+	 * <p>
+	 * <li>If <code>oneLineCoded</code> is empty or null, NO TRANSLATION is set.
+	 * <li>If format can't be recognized, the {@link String} is interpreted as
+	 * the translation in the <code>{@value #DEFAULT_KEY}</code> language
+	 * 
 	 * @author Stefan Alfons Krüger
+	 */
+	public static Translation createFromOneLIne(final String oneLineCoded) {
+		Translation result = new Translation();
+		result.fromOneLine(oneLineCoded);
+		return result;
+	}
+
+	/**
+	 * Returns the Translation to a String of the Format: "de{Baum}en{tree}" <br/>
+	 * 
+	 * 
+	 * @author Stefan Alfons Krüger
+	 */
+	public static String toOneLine(Translation source) {
+		StringBuffer oneLine = new StringBuffer();
+		for (String key : source.keySet()) {
+			oneLine.append(key + "{" + source.get(key) + "}");
+		}
+		return oneLine.toString();
+	}
+
+	/**
+	 * @author Stefan Alfons Krüger
 	 * @param code
 	 * @return true if the code paramter is a valid ISO Language code
 	 */
@@ -47,7 +76,7 @@
 			if (l.getLanguage().equals(code.toLowerCase())) {
 				return l;
 			}
-//			LOGGER.debug(l.getLanguage() + " not = " + code);
+			// LOGGER.debug(l.getLanguage() + " not = " + code);
 		}
 
 		LOGGER.error("Can't create a Locale for code " + code

Modified: trunk/src/skrueger/i8n/Translation.java
===================================================================
--- trunk/src/skrueger/i8n/Translation.java	2009-07-03 13:11:18 UTC (rev 184)
+++ trunk/src/skrueger/i8n/Translation.java	2009-07-03 14:36:08 UTC (rev 185)
@@ -8,6 +8,7 @@
 import java.util.Locale;
 
 import javax.swing.JComponent;
+import javax.swing.JTable;
 
 import org.apache.log4j.Logger;
 
@@ -89,21 +90,20 @@
 	}
 
 	/**
-	 * Initializes a new {@link Translation} with a default translation. Other
-	 * translations may be added later.
+	 * Initializes a new {@link Translation} with a default translation if a
+	 * simple text is passed. If a "oneLine" text is parsed, it is
+	 * interpreted. Other translations may be added later - this is a HashMap<br/>
 	 * 
 	 * @param defaultTranslation
 	 * 
-	 * @deprecated SK: The concept of the default translation doesn't seem so
-	 *             nice to me anymore.. I would prefer the default translation
-	 *             to be set for all valid languages.
-	 * 
 	 * @see public Translation(List<String> languages, String
 	 *      defaultTranslation) {
 	 * 
 	 */
 	public Translation(String defaultTranslation) {
-		put(DEFAULT_KEY, defaultTranslation);
+
+		fromOneLine(defaultTranslation);
+
 	}
 
 	/**
@@ -174,11 +174,7 @@
 	 * @author Stefan Alfons Krüger
 	 */
 	public String toOneLine() {
-		StringBuffer oneLine = new StringBuffer();
-		for (String key : keySet()) {
-			oneLine.append(key + "{" + get(key) + "}");
-		}
-		return oneLine.toString();
+		return I8NUtil.toOneLine(this);
 	}
 
 	/**
@@ -206,7 +202,7 @@
 		// MS:
 		else {
 			if (get(DEFAULT_KEY) != null) {
-				// log.debug("default lng returned, cuz the translation to "+activeLang+" was not found. Schmeiss raus martin, wenn du das mit der default trans geklärt hast.");
+				// log.debug("default lang returned, cuz the translation to "+activeLang+" was not found. Schmeiss raus martin, wenn du das mit der default trans geklärt hast.");
 				return get(DEFAULT_KEY);
 			}
 
@@ -262,5 +258,4 @@
 		}
 	}
 
-
 }



More information about the Schmitzm-commits mailing list