Title: [waffle-scm] [687] trunk/examples/simple-example/src/main/resources: Added default implementation of MessageResourcesConfiguration.
Revision
687
Author
mauro
Date
2008-06-05 14:20:42 -0500 (Thu, 05 Jun 2008)

Log Message

Added default implementation of MessageResourcesConfiguration. 
Renamed resource bundle used in examples so they can co-exist in the same classpath without conflicting with core.

Modified Paths

Added Paths

Removed Paths

Diff

Deleted: trunk/examples/freemarker-example/src/main/resources/ApplicationResources.properties (686 => 687)

--- trunk/examples/freemarker-example/src/main/resources/ApplicationResources.properties	2008-06-05 18:14:08 UTC (rev 686)
+++ trunk/examples/freemarker-example/src/main/resources/ApplicationResources.properties	2008-06-05 19:20:42 UTC (rev 687)
@@ -1,12 +0,0 @@
-# Binding Error Messages
-bind.error.default=The value ''{1}'' entered in field <i>{0}</i> is not valid.
-bind.error.number=The value ''{1}'' entered in field <i>{0}</i> is not a valid number.
-bind.error.date=The value "{1}" entered in field <i>{0}</i> is not a valid date ({2}).
-
-# Other Error messages
-
-# Field Descriptions
-dateOfBirth=Date of Birth
-
-# Other properties
-

Copied: trunk/examples/freemarker-example/src/main/resources/FreemarkerResources.properties (from rev 684, trunk/examples/freemarker-example/src/main/resources/ApplicationResources.properties) (0 => 687)

--- trunk/examples/freemarker-example/src/main/resources/FreemarkerResources.properties	                        (rev 0)
+++ trunk/examples/freemarker-example/src/main/resources/FreemarkerResources.properties	2008-06-05 19:20:42 UTC (rev 687)
@@ -0,0 +1,12 @@
+# Binding Error Messages
+bind.error.default=The value ''{1}'' entered in field <i>{0}</i> is not valid.
+bind.error.number=The value ''{1}'' entered in field <i>{0}</i> is not a valid number.
+bind.error.date=The value "{1}" entered in field <i>{0}</i> is not a valid date ({2}).
+
+# Other Error messages
+
+# Field Descriptions
+dateOfBirth=Date of Birth
+
+# Other properties
+

Deleted: trunk/examples/mydvds-example/src/main/resources/ApplicationResources.properties (686 => 687)

--- trunk/examples/mydvds-example/src/main/resources/ApplicationResources.properties	2008-06-05 18:14:08 UTC (rev 686)
+++ trunk/examples/mydvds-example/src/main/resources/ApplicationResources.properties	2008-06-05 19:20:42 UTC (rev 687)
@@ -1,26 +0,0 @@
-# Automatic Binding Error Messages
-bind.error.default=The value ''{1}'' entered in field <i>{0}</i> is not valid.
-bind.error.number=The value ''{1}'' entered in field <i>{0}</i> is not a valid number.
-bind.error.date=The value "{1}" entered in field <i>{0}</i> is not a valid date ({2}).
-
-# Other Error messages
-invalid_name = Invalid Name
-invalid_login = Invalid Login
-invalid_password = Invalid Password
-
-# Field Descriptions
-welcome=Welcome
-change_language=Change Language
-new_user=New User
-login_page=Login
-logout=Logout
-your_dvds=Your Dvds
-new_dvd=New Dvd
-add=Add
-dvd.title=Dvd title
-dvd.description=Dvd description
-dvd.type=Dvd type
-name=name
-login=login
-password=password
-errors=Errors

Deleted: trunk/examples/mydvds-example/src/main/resources/ApplicationResources_de.properties (686 => 687)

--- trunk/examples/mydvds-example/src/main/resources/ApplicationResources_de.properties	2008-06-05 18:14:08 UTC (rev 686)
+++ trunk/examples/mydvds-example/src/main/resources/ApplicationResources_de.properties	2008-06-05 19:20:42 UTC (rev 687)
@@ -1,23 +0,0 @@
-bind.error.default=''{1}'' in <i>{0}</i> ist ung&uuml;ltige.
-bind.error.number=''{1}'' in <i>{0}</i> ist ein Ung&uuml;ltige Nummer.
-bind.error.date="{1}" in <i>{0}</i> ist ein ung&uuml;ltiges Datum. ({2}).
-
-invalid_name = Ung&uuml;ltige Name
-invalid_login = Ung&uuml;ltige Benutzername
-invalid_password = Ung&uuml;ltige Passwort
-
-welcome=Herzlich Willkommen
-change_language=W&auml;hlen Sie Ihre Sprache
-new_user=Noch nicht registriert?
-login_page=Login-Seite
-logout=Logout
-your_dvds=Deine DVDs
-new_dvd=Neue DVD
-add=Senden
-dvd.title=Titel
-dvd.description=Beschreibung
-dvd.type=Typ
-name=Name
-login=Benutzername
-password=Passwort
-errors=Fehler
\ No newline at end of file

Deleted: trunk/examples/mydvds-example/src/main/resources/ApplicationResources_it.properties (686 => 687)

--- trunk/examples/mydvds-example/src/main/resources/ApplicationResources_it.properties	2008-06-05 18:14:08 UTC (rev 686)
+++ trunk/examples/mydvds-example/src/main/resources/ApplicationResources_it.properties	2008-06-05 19:20:42 UTC (rev 687)
@@ -1,16 +0,0 @@
-# Field Descriptions
-welcome=Benvenuti
-change_language=Cambia Lingua
-new_user=Nuovo Utente
-login_page=Login
-logout=Logout
-your_dvds=I tuoi Dvd
-new_dvd=Nuovo Dvd
-add=Aggiungi
-dvd.title=Titolo Dvd
-dvd.description=Descrizione Dvd
-dvd.type=Tipo Dvd
-name=nome
-login=login
-password=password
-errors=??Errors??
\ No newline at end of file

Deleted: trunk/examples/mydvds-example/src/main/resources/ApplicationResources_pt_BR.properties (686 => 687)

--- trunk/examples/mydvds-example/src/main/resources/ApplicationResources_pt_BR.properties	2008-06-05 18:14:08 UTC (rev 686)
+++ trunk/examples/mydvds-example/src/main/resources/ApplicationResources_pt_BR.properties	2008-06-05 19:20:42 UTC (rev 687)
@@ -1,23 +0,0 @@
-bind.error.default=O valor ''{1}'' passado no campo <i>{0}</i> n&atilde;o &eacute; v&aacute;lido.
-bind.error.number=O valor ''{1}'' passado no campo <i>{0}</i> n&atilde;o &eacute; um n&uacute;mero v&aacute;lido.
-bind.error.date=O valor "{1}" passado no campo <i>{0}</i> n&atilde;o &eacute; uma data v&aacute;lida ({2}).
-
-invalid_name = Nome inv&aacute;lido
-invalid_login = Login inv&aacute;lido
-invalid_password = Senha inv&aacute;lida
-
-welcome=Bem vindo
-change_language=Mudar a l&iacute;ngua
-new_user=Novo usu&aacute;rio
-login_page=Entrar
-logout=Sair
-your_dvds=Seus Dvds
-new_dvd=Novo Dvd
-add=Adicionar
-dvd.title=T&iacute;tulo
-dvd.description=Descri&ccedil;&atilde;o
-dvd.type=Tipo do Dvd
-name=nome
-login=login
-password=senha
-errors=Erros
\ No newline at end of file

Added: trunk/examples/mydvds-example/src/main/resources/MyDvdsResources.properties (0 => 687)

--- trunk/examples/mydvds-example/src/main/resources/MyDvdsResources.properties	                        (rev 0)
+++ trunk/examples/mydvds-example/src/main/resources/MyDvdsResources.properties	2008-06-05 19:20:42 UTC (rev 687)
@@ -0,0 +1,26 @@
+# Automatic Binding Error Messages
+bind.error.default=The value ''{1}'' entered in field <i>{0}</i> is not valid.
+bind.error.number=The value ''{1}'' entered in field <i>{0}</i> is not a valid number.
+bind.error.date=The value "{1}" entered in field <i>{0}</i> is not a valid date ({2}).
+
+# Other Error messages
+invalid_name = Invalid Name
+invalid_login = Invalid Login
+invalid_password = Invalid Password
+
+# Field Descriptions
+welcome=Welcome
+change_language=Change Language
+new_user=New User
+login_page=Login
+logout=Logout
+your_dvds=Your Dvds
+new_dvd=New Dvd
+add=Add
+dvd.title=Dvd title
+dvd.description=Dvd description
+dvd.type=Dvd type
+name=name
+login=login
+password=password
+errors=Errors

Added: trunk/examples/mydvds-example/src/main/resources/MyDvdsResources_de.properties (0 => 687)

--- trunk/examples/mydvds-example/src/main/resources/MyDvdsResources_de.properties	                        (rev 0)
+++ trunk/examples/mydvds-example/src/main/resources/MyDvdsResources_de.properties	2008-06-05 19:20:42 UTC (rev 687)
@@ -0,0 +1,23 @@
+bind.error.default=''{1}'' in <i>{0}</i> ist ung&uuml;ltige.
+bind.error.number=''{1}'' in <i>{0}</i> ist ein Ung&uuml;ltige Nummer.
+bind.error.date="{1}" in <i>{0}</i> ist ein ung&uuml;ltiges Datum. ({2}).
+
+invalid_name = Ung&uuml;ltige Name
+invalid_login = Ung&uuml;ltige Benutzername
+invalid_password = Ung&uuml;ltige Passwort
+
+welcome=Herzlich Willkommen
+change_language=W&auml;hlen Sie Ihre Sprache
+new_user=Noch nicht registriert?
+login_page=Login-Seite
+logout=Logout
+your_dvds=Deine DVDs
+new_dvd=Neue DVD
+add=Senden
+dvd.title=Titel
+dvd.description=Beschreibung
+dvd.type=Typ
+name=Name
+login=Benutzername
+password=Passwort
+errors=Fehler
\ No newline at end of file

Added: trunk/examples/mydvds-example/src/main/resources/MyDvdsResources_it.properties (0 => 687)

--- trunk/examples/mydvds-example/src/main/resources/MyDvdsResources_it.properties	                        (rev 0)
+++ trunk/examples/mydvds-example/src/main/resources/MyDvdsResources_it.properties	2008-06-05 19:20:42 UTC (rev 687)
@@ -0,0 +1,16 @@
+# Field Descriptions
+welcome=Benvenuti
+change_language=Cambia Lingua
+new_user=Nuovo Utente
+login_page=Login
+logout=Logout
+your_dvds=I tuoi Dvd
+new_dvd=Nuovo Dvd
+add=Aggiungi
+dvd.title=Titolo Dvd
+dvd.description=Descrizione Dvd
+dvd.type=Tipo Dvd
+name=nome
+login=login
+password=password
+errors=??Errors??
\ No newline at end of file

Added: trunk/examples/mydvds-example/src/main/resources/MyDvdsResources_pt_BR.properties (0 => 687)

--- trunk/examples/mydvds-example/src/main/resources/MyDvdsResources_pt_BR.properties	                        (rev 0)
+++ trunk/examples/mydvds-example/src/main/resources/MyDvdsResources_pt_BR.properties	2008-06-05 19:20:42 UTC (rev 687)
@@ -0,0 +1,23 @@
+bind.error.default=O valor ''{1}'' passado no campo <i>{0}</i> n&atilde;o &eacute; v&aacute;lido.
+bind.error.number=O valor ''{1}'' passado no campo <i>{0}</i> n&atilde;o &eacute; um n&uacute;mero v&aacute;lido.
+bind.error.date=O valor "{1}" passado no campo <i>{0}</i> n&atilde;o &eacute; uma data v&aacute;lida ({2}).
+
+invalid_name = Nome inv&aacute;lido
+invalid_login = Login inv&aacute;lido
+invalid_password = Senha inv&aacute;lida
+
+welcome=Bem vindo
+change_language=Mudar a l&iacute;ngua
+new_user=Novo usu&aacute;rio
+login_page=Entrar
+logout=Sair
+your_dvds=Seus Dvds
+new_dvd=Novo Dvd
+add=Adicionar
+dvd.title=T&iacute;tulo
+dvd.description=Descri&ccedil;&atilde;o
+dvd.type=Tipo do Dvd
+name=nome
+login=login
+password=senha
+errors=Erros
\ No newline at end of file

Deleted: trunk/examples/paranamer-example/src/main/resources/ApplicationResources.properties (686 => 687)

--- trunk/examples/paranamer-example/src/main/resources/ApplicationResources.properties	2008-06-05 18:14:08 UTC (rev 686)
+++ trunk/examples/paranamer-example/src/main/resources/ApplicationResources.properties	2008-06-05 19:20:42 UTC (rev 687)
@@ -1,11 +0,0 @@
-# Binding Error Messages
-bind.error.default=The value ''{1}'' entered in field <i>{0}</i> is not valid.
-bind.error.number=The value ''{1}'' entered in field <i>{0}</i> is not a valid number.
-bind.error.date=The value "{1}" entered in field <i>{0}</i> is not a valid date ({2}).
-
-# Other Error messages
-
-# Field Descriptions
-dateOfBirth=Date of Birth
-
-# Other properties
\ No newline at end of file

Copied: trunk/examples/paranamer-example/src/main/resources/ParanamerResources.properties (from rev 684, trunk/examples/paranamer-example/src/main/resources/ApplicationResources.properties) (0 => 687)

--- trunk/examples/paranamer-example/src/main/resources/ParanamerResources.properties	                        (rev 0)
+++ trunk/examples/paranamer-example/src/main/resources/ParanamerResources.properties	2008-06-05 19:20:42 UTC (rev 687)
@@ -0,0 +1,11 @@
+# Binding Error Messages
+bind.error.default=The value ''{1}'' entered in field <i>{0}</i> is not valid.
+bind.error.number=The value ''{1}'' entered in field <i>{0}</i> is not a valid number.
+bind.error.date=The value "{1}" entered in field <i>{0}</i> is not a valid date ({2}).
+
+# Other Error messages
+
+# Field Descriptions
+dateOfBirth=Date of Birth
+
+# Other properties
\ No newline at end of file

Deleted: trunk/examples/simple-example/src/main/resources/ApplicationResources.properties (686 => 687)

--- trunk/examples/simple-example/src/main/resources/ApplicationResources.properties	2008-06-05 18:14:08 UTC (rev 686)
+++ trunk/examples/simple-example/src/main/resources/ApplicationResources.properties	2008-06-05 19:20:42 UTC (rev 687)
@@ -1,16 +0,0 @@
-# Binding Error Messages
-bind.error.default=The value ''{1}'' entered in field <i>{0}</i> is not valid.
-bind.error.number=The value ''{1}'' entered in field <i>{0}</i> is not a valid number.
-bind.error.date=The value "{1}" entered in field <i>{0}</i> is not a valid date ({2}).
-
-# Properties
-car.make=Ford
-car.model=GT-40
-date.format=dd-MM-yyyy
-
-speed.error=Speed can NOT exceed the top speed [{0}]
-
-topSpeed=Top Speed
-
-dateOfBirth=Date of Birth
-

Copied: trunk/examples/simple-example/src/main/resources/SimpleResources.properties (from rev 684, trunk/examples/simple-example/src/main/resources/ApplicationResources.properties) (0 => 687)

--- trunk/examples/simple-example/src/main/resources/SimpleResources.properties	                        (rev 0)
+++ trunk/examples/simple-example/src/main/resources/SimpleResources.properties	2008-06-05 19:20:42 UTC (rev 687)
@@ -0,0 +1,16 @@
+# Binding Error Messages
+bind.error.default=The value ''{1}'' entered in field <i>{0}</i> is not valid.
+bind.error.number=The value ''{1}'' entered in field <i>{0}</i> is not a valid number.
+bind.error.date=The value "{1}" entered in field <i>{0}</i> is not a valid date ({2}).
+
+# Properties
+car.make=Ford
+car.model=GT-40
+date.format=dd-MM-yyyy
+
+speed.error=Speed can NOT exceed the top speed [{0}]
+
+topSpeed=Top Speed
+
+dateOfBirth=Date of Birth
+

Modified: trunk/examples/simple-example/src/test/java/org/codehaus/waffle/example/simple/AutomobileControllerValidatorTest.java (686 => 687)

--- trunk/examples/simple-example/src/test/java/org/codehaus/waffle/example/simple/AutomobileControllerValidatorTest.java	2008-06-05 18:14:08 UTC (rev 686)
+++ trunk/examples/simple-example/src/test/java/org/codehaus/waffle/example/simple/AutomobileControllerValidatorTest.java	2008-06-05 19:20:42 UTC (rev 687)
@@ -1,17 +1,20 @@
 package org.codehaus.waffle.example.simple;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import java.util.Locale;
+
 import org.codehaus.waffle.i18n.DefaultMessageResources;
+import org.codehaus.waffle.i18n.DefaultMessageResourcesConfiguration;
 import org.codehaus.waffle.i18n.MessageResources;
 import org.codehaus.waffle.validation.DefaultErrorsContext;
 import org.codehaus.waffle.validation.ErrorMessage;
 import org.codehaus.waffle.validation.ErrorsContext;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
 import org.junit.Test;
 
-import java.util.List;
-
 public class AutomobileControllerValidatorTest {
 
     @Test
@@ -31,7 +34,7 @@
 
     @Test
     public void canValidateHasErrors() {
-        MessageResources messageResources = new DefaultMessageResources();
+        MessageResources messageResources = new DefaultMessageResources(new DefaultMessageResourcesConfiguration(Locale.getDefault(), "SimpleResources"));
 
         AutomobileController controller = new AutomobileController();
         controller.setSpeed(140);

Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/i18n/DefaultMessageResources.java (686 => 687)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/i18n/DefaultMessageResources.java	2008-06-05 18:14:08 UTC (rev 686)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/i18n/DefaultMessageResources.java	2008-06-05 19:20:42 UTC (rev 687)
@@ -28,8 +28,7 @@
     public final String bundleName;
 
     public DefaultMessageResources() {
-        bundleName = "ApplicationResources";
-        userLocale.set(Locale.getDefault());
+        this(new DefaultMessageResourcesConfiguration());
     }
 
     public DefaultMessageResources(MessageResourcesConfiguration configuration) {

Added: trunk/waffle-core/src/main/java/org/codehaus/waffle/i18n/DefaultMessageResourcesConfiguration.java (0 => 687)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/i18n/DefaultMessageResourcesConfiguration.java	                        (rev 0)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/i18n/DefaultMessageResourcesConfiguration.java	2008-06-05 19:20:42 UTC (rev 687)
@@ -0,0 +1,32 @@
+package org.codehaus.waffle.i18n;
+
+import java.util.Locale;
+
+/**
+ * Default MessageResourcesConfiguration
+ * 
+ * @author Mauro Talevi
+ */
+public class DefaultMessageResourcesConfiguration implements MessageResourcesConfiguration {
+
+    private final Locale defaultLocale;
+    private final String bundleName;
+
+    public DefaultMessageResourcesConfiguration() {
+        this(Locale.getDefault(), "ApplicationResources");
+    }
+
+    public DefaultMessageResourcesConfiguration(Locale defaultLocale, String bundleName) {
+        this.defaultLocale = defaultLocale;
+        this.bundleName = bundleName;
+    }
+
+    public Locale getDefaultLocale() {
+        return defaultLocale;
+    }
+
+    public String getResourceBundleName() {
+        return bundleName;
+    }
+
+}


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to