[Schmitzm-commits] r37 - in trunk: dist src/skrueger/i8n

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Mar 30 02:43:09 CEST 2009


Author: alfonx
Date: 2009-03-30 02:43:08 +0200 (Mon, 30 Mar 2009)
New Revision: 37

Modified:
   trunk/dist/schmitzm.jar
   trunk/src/skrueger/i8n/Translation.java
Log:
Now Translation doesn't fires LocaleChangeEvents if newLang.equals(oldLang)

Modified: trunk/dist/schmitzm.jar
===================================================================
(Binary files differ)

Modified: trunk/src/skrueger/i8n/Translation.java
===================================================================
--- trunk/src/skrueger/i8n/Translation.java	2009-03-29 22:19:52 UTC (rev 36)
+++ trunk/src/skrueger/i8n/Translation.java	2009-03-30 00:43:08 UTC (rev 37)
@@ -51,15 +51,20 @@
 	}
 
 	/**
-	 * Set up the {@link Translation}-system to use language.
-	 * @param activeLang
+	 * Set up the {@link Translation}-system to use language. If a change is performed, events are fired to listeners. Nothing is done if the new language equals the old language.
+	 * 
+	 * @param newLang The ISO Code of the new active language
 	 */
-	public static void setActiveLang(String activeLang) {
-		if (!I8NUtil.isValidISOLangCode(activeLang)) {
-			throw new IllegalArgumentException("'"+activeLang+"' is not a valid ISO language code.");
+	public static void setActiveLang(String newLang) {
+		if (getActiveLang().equals(newLang)) {
+			return;
 		}
+		
+		if (!I8NUtil.isValidISOLangCode(newLang)) {
+			throw new IllegalArgumentException("'"+newLang+"' is not a valid ISO language code.");
+		}
 
-		Locale newLocale = new Locale(activeLang);
+		Locale newLocale = new Locale(newLang);
 		Locale.setDefault(newLocale);
 		
 		/**
@@ -68,11 +73,11 @@
 		 */
 		JComponent.setDefaultLocale(newLocale);
 		
-		Translation.activeLang = activeLang;
+		Translation.activeLang = newLang;
 		
 		fireChangeEvents();
 		
-		log.info("skrueger.i8n.Translation switched ActiveLang to "+activeLang);
+		log.info("skrueger.i8n.Translation switched ActiveLang to "+newLang);
 	}
 
 	/**



More information about the Schmitzm-commits mailing list