Refactored internal api
This commit is contained in:
parent
3f31bb8a3a
commit
6ccd763d1f
361 changed files with 23049 additions and 4498 deletions
|
|
@ -1,8 +1,11 @@
|
|||
package net.forwardfire.vasc.lib.i18n;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle;
|
||||
import net.forwardfire.vasc.lib.i18n.config.BundleConfig;
|
||||
import net.forwardfire.vasc.lib.i18n.config.BundleConfigParser;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
|
@ -15,16 +18,34 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
public class RootBundleTest extends TestCase {
|
||||
|
||||
static private final String TEST_BUNDLE = RootApplicationBundle.URI;
|
||||
static private final Locale TEST_LOCALE = new Locale("en");
|
||||
static private final Locale TEST_LOCALE_NL = new Locale("nl");
|
||||
|
||||
public void testParser() {
|
||||
BundleConfigParser p = new BundleConfigParser();
|
||||
p.parseConfig();
|
||||
assertEquals(2,p.getBundleConfigs().size());
|
||||
assertEquals(2,p.getApplicationSupportedLocales().size());
|
||||
}
|
||||
|
||||
public void testBundleOrder() {
|
||||
BundleConfigParser p = new BundleConfigParser();
|
||||
p.parseConfig();
|
||||
List<BundleConfig> conf = p.getBundleConfigs();
|
||||
assertTrue(conf.isEmpty()==false);
|
||||
BundleConfig bundle = conf.get(0);
|
||||
assertEquals("bundle2",bundle.getName());
|
||||
}
|
||||
|
||||
public void testBundleOrderValue() {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle(TEST_BUNDLE,TEST_LOCALE);
|
||||
assertEquals("bundle1",bundle.getString("bundle.key"));
|
||||
}
|
||||
|
||||
public void testValues_en() {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle",new Locale("en"));
|
||||
assertEquals(6,bundle.keySet().size());
|
||||
ResourceBundle bundle = ResourceBundle.getBundle(TEST_BUNDLE,TEST_LOCALE);
|
||||
assertEquals(7,bundle.keySet().size());
|
||||
assertEquals("key1_en",bundle.getString("bundle1.key1"));
|
||||
assertEquals("key2_en",bundle.getString("bundle1.key2"));
|
||||
assertEquals("key3_en",bundle.getString("bundle1.key3"));
|
||||
|
|
@ -34,8 +55,8 @@ public class RootBundleTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testValues_nl() {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle",new Locale("nl"));
|
||||
assertEquals(6,bundle.keySet().size());
|
||||
ResourceBundle bundle = ResourceBundle.getBundle(TEST_BUNDLE,TEST_LOCALE_NL);
|
||||
assertEquals(7,bundle.keySet().size());
|
||||
assertEquals("key1_nl",bundle.getString("bundle1.key1"));
|
||||
assertEquals("key2_nl",bundle.getString("bundle1.key2"));
|
||||
assertEquals("key3_nl",bundle.getString("bundle1.key3"));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
|
||||
# Default config
|
||||
config.charset=UTF-8
|
||||
config.bundles=bundle2,bundle1
|
||||
|
||||
# We only suport 2 languages.
|
||||
locale.nl=true
|
||||
locale.en=true
|
||||
|
|
@ -7,12 +11,13 @@ locale.en=true
|
|||
bundle1.uri=net.forwardfire.vasc.lib.i18n.resources.TestBundle1
|
||||
bundle2.uri=net.forwardfire.vasc.lib.i18n.resources.TestBundle2
|
||||
|
||||
# TODO:
|
||||
#
|
||||
# Bundle options;
|
||||
#
|
||||
# bundle2.type=RESOURCE
|
||||
# bundle2.exclude=yoyo.*
|
||||
# bundle2.format=PROPERTIES
|
||||
# bundle2.utf8=true
|
||||
# bundle2.charset=UTF-8
|
||||
# bundle2.optional=false
|
||||
#
|
||||
# bundle3.uri=http://foo.bar/some/path/bundle.properties
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
# Test bundle
|
||||
bundle.key = bundle1
|
||||
bundle1.key1 = key1_en
|
||||
bundle1.key2 = key2_en
|
||||
bundle1.key3 = key3_en
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
# Test bundle
|
||||
bundle.key = bundle1
|
||||
bundle1.key1 = key1_nl
|
||||
bundle1.key2 = key2_nl
|
||||
bundle1.key3 = key3_nl
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
# Test bundle
|
||||
bundle.key = bundle2
|
||||
bundle2.key1 = key1_en
|
||||
bundle2.key2 = key2_en
|
||||
bundle2.key3 = key3_en
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
# Test bundle
|
||||
bundle.key = bundle2
|
||||
bundle2.key1 = key1_nl
|
||||
bundle2.key2 = key2_nl
|
||||
bundle2.key3 = key3_nl
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue