You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by lu...@apache.org on 2011/04/07 15:47:17 UTC
svn commit: r1089882 - in /turbine/fulcrum/trunk/localization/src:
java/org/apache/fulcrum/localization/ test/org/apache/fulcrum/localization/
Author: ludwig
Date: Thu Apr 7 13:47:17 2011
New Revision: 1089882
URL: http://svn.apache.org/viewvc?rev=1089882&view=rev
Log:
Added method previously available for easy access of values in the default bundle with the default locale.
Modified:
turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/SimpleLocalizationService.java
turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java
turbine/fulcrum/trunk/localization/src/test/org/apache/fulcrum/localization/LocalizationTest.java
Modified: turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/SimpleLocalizationService.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/SimpleLocalizationService.java?rev=1089882&r1=1089881&r2=1089882&view=diff
==============================================================================
--- turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/SimpleLocalizationService.java (original)
+++ turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/SimpleLocalizationService.java Thu Apr 7 13:47:17 2011
@@ -119,6 +119,14 @@ public interface SimpleLocalizationServi
* @return Localized text.
*/
String getString(String bundleName, Locale locale, String key) throws MissingResourceException;
+
+ /**
+ * Returns the value for the key in the default bundle and the default locale.
+ *
+ * @param key The key to retrieve the value for.
+ * @return The value mapped to the key.
+ */
+ String getString(String key);
/**
* This method sets the name of the defaultBundle.
Modified: turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java?rev=1089882&r1=1089881&r2=1089882&view=diff
==============================================================================
--- turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java (original)
+++ turbine/fulcrum/trunk/localization/src/java/org/apache/fulcrum/localization/SimpleLocalizationServiceImpl.java Thu Apr 7 13:47:17 2011
@@ -495,6 +495,17 @@ public class SimpleLocalizationServiceIm
}
/**
+ * Returns the value for the key in the default bundle and the default locale.
+ *
+ * @param key The key to retrieve the value for.
+ * @return The value mapped to the key.
+ */
+ public String getString(String key) {
+ return getString(getDefaultBundleName(), getDefaultLocale(), key);
+ }
+
+
+ /**
* Gets localized text from a bundle if it's there. Otherwise,
* returns <code>null</code> (ignoring a possible
* <code>MissingResourceException</code>).
Modified: turbine/fulcrum/trunk/localization/src/test/org/apache/fulcrum/localization/LocalizationTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/localization/src/test/org/apache/fulcrum/localization/LocalizationTest.java?rev=1089882&r1=1089881&r2=1089882&view=diff
==============================================================================
--- turbine/fulcrum/trunk/localization/src/test/org/apache/fulcrum/localization/LocalizationTest.java (original)
+++ turbine/fulcrum/trunk/localization/src/test/org/apache/fulcrum/localization/LocalizationTest.java Thu Apr 7 13:47:17 2011
@@ -95,6 +95,25 @@ public class LocalizationTest extends Ba
// Asked for key from default bundle which does not exist,
}
}
+
+
+ public void testGetString() {
+ String key1 = "key1";
+ String value1 = "value1";
+ String key2 = "key2";
+ String value2 = "value2";
+ String key3 = "key3";
+ String value3 = "value3";
+ String key4 = "key4";
+ String value4 = "value4";
+
+ assertEquals(value1, ls.getString(key1));
+ assertEquals(value2, ls.getString(key2));
+ assertEquals(value3, ls.getString(key3));
+ assertEquals(value4, ls.getString(key4));
+
+ }
+
/**
* Putting this in a seperate testcase because it fails.. Why? I don't know. I have never
* used localization, so I leave it to brains better then mine. -dep