- 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
- trunk/examples/simple-example/src/test/java/org/codehaus/waffle/example/simple/AutomobileControllerValidatorTest.java
- trunk/waffle-core/src/main/java/org/codehaus/waffle/i18n/DefaultMessageResources.java
Added Paths
- trunk/examples/freemarker-example/src/main/resources/FreemarkerResources.properties
- trunk/examples/mydvds-example/src/main/resources/MyDvdsResources.properties
- trunk/examples/mydvds-example/src/main/resources/MyDvdsResources_de.properties
- trunk/examples/mydvds-example/src/main/resources/MyDvdsResources_it.properties
- trunk/examples/mydvds-example/src/main/resources/MyDvdsResources_pt_BR.properties
- trunk/examples/paranamer-example/src/main/resources/ParanamerResources.properties
- trunk/examples/simple-example/src/main/resources/SimpleResources.properties
- trunk/waffle-core/src/main/java/org/codehaus/waffle/i18n/DefaultMessageResourcesConfiguration.java
Removed Paths
- trunk/examples/freemarker-example/src/main/resources/ApplicationResources.properties
- trunk/examples/mydvds-example/src/main/resources/ApplicationResources.properties
- trunk/examples/mydvds-example/src/main/resources/ApplicationResources_de.properties
- trunk/examples/mydvds-example/src/main/resources/ApplicationResources_it.properties
- trunk/examples/mydvds-example/src/main/resources/ApplicationResources_pt_BR.properties
- trunk/examples/paranamer-example/src/main/resources/ApplicationResources.properties
- trunk/examples/simple-example/src/main/resources/ApplicationResources.properties
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ültige. -bind.error.number=''{1}'' in <i>{0}</i> ist ein Ungültige Nummer. -bind.error.date="{1}" in <i>{0}</i> ist ein ungültiges Datum. ({2}). - -invalid_name = Ungültige Name -invalid_login = Ungültige Benutzername -invalid_password = Ungültige Passwort - -welcome=Herzlich Willkommen -change_language=Wä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ão é válido. -bind.error.number=O valor ''{1}'' passado no campo <i>{0}</i> não é um número válido. -bind.error.date=O valor "{1}" passado no campo <i>{0}</i> não é uma data válida ({2}). - -invalid_name = Nome inválido -invalid_login = Login inválido -invalid_password = Senha inválida - -welcome=Bem vindo -change_language=Mudar a língua -new_user=Novo usuário -login_page=Entrar -logout=Sair -your_dvds=Seus Dvds -new_dvd=Novo Dvd -add=Adicionar -dvd.title=Título -dvd.description=Descriçã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ültige. +bind.error.number=''{1}'' in <i>{0}</i> ist ein Ungültige Nummer. +bind.error.date="{1}" in <i>{0}</i> ist ein ungültiges Datum. ({2}). + +invalid_name = Ungültige Name +invalid_login = Ungültige Benutzername +invalid_password = Ungültige Passwort + +welcome=Herzlich Willkommen +change_language=Wä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ão é válido. +bind.error.number=O valor ''{1}'' passado no campo <i>{0}</i> não é um número válido. +bind.error.date=O valor "{1}" passado no campo <i>{0}</i> não é uma data válida ({2}). + +invalid_name = Nome inválido +invalid_login = Login inválido +invalid_password = Senha inválida + +welcome=Bem vindo +change_language=Mudar a língua +new_user=Novo usuário +login_page=Entrar +logout=Sair +your_dvds=Seus Dvds +new_dvd=Novo Dvd +add=Adicionar +dvd.title=Título +dvd.description=Descriçã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:
