Author: tchemit Date: 2014-05-16 15:13:49 +0200 (Fri, 16 May 2014) New Revision: 3961 Url: http://forge.chorem.org/projects/pollen/repository/revisions/3961 Log: i18n on validation Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java 2014-05-16 12:26:45 UTC (rev 3960) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java 2014-05-16 13:13:49 UTC (rev 3961) @@ -115,7 +115,7 @@ */ DEFAULT_CHOICE_TYPE( "pollen.default.pollChoiceType", - n("pollen.configuration.pollChoiceType"), + n("pollen.configuration.defaultPollChoiceType"), ChoiceType.TEXT.name(), ChoiceType.class), Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-05-16 12:26:45 UTC (rev 3960) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-05-16 13:13:49 UTC (rev 3961) @@ -41,6 +41,8 @@ import java.util.List; import java.util.Set; +import static org.nuiton.i18n.I18n.l; + /** * TODO * @@ -340,12 +342,13 @@ ErrorMap errors = new ErrorMap(); - checkNotNull(errors, Poll.PROPERTY_POLL_TYPE, poll.getPollType(), "pollType can not be null"); - checkNotNull(errors, Poll.PROPERTY_COMMENT_VISIBILITY, poll.getCommentVisibility(), "commentVisibility can not be null"); - checkNotNull(errors, Poll.PROPERTY_VOTE_VISIBILITY, poll.getVoteVisibility(), "voteVisibility can not be null"); - checkNotNull(errors, Poll.PROPERTY_VOTE_COUNTING_TYPE, poll.getVoteCountingType(), "voteCountingType can not be null"); + checkNotNull(errors, Poll.PROPERTY_POLL_TYPE, poll.getPollType(), l(getLocale(), "pollen.error.poll.pollType.mandatory")); + checkNotNull(errors, Poll.PROPERTY_COMMENT_VISIBILITY, poll.getCommentVisibility(), l(getLocale(), "pollen.error.poll.pollType.mandatory commentVisibility")); + checkNotNull(errors, Poll.PROPERTY_VOTE_VISIBILITY, poll.getVoteVisibility(), l(getLocale(), "pollen.error.poll.voteVisibility.mandatory")); + checkNotNull(errors, Poll.PROPERTY_RESULT_VISIBILITY, poll.getResultVisibility(), l(getLocale(), "pollen.error.poll.resultVisibility.mandatory")); + checkNotNull(errors, Poll.PROPERTY_VOTE_COUNTING_TYPE, poll.getVoteCountingType(), l(getLocale(), "pollen.error.poll.voteCountingType.mandatory")); - checkNotBlank(errors, Poll.PROPERTY_TITLE, poll.getTitle(), "title can not be empty"); + checkNotBlank(errors, Poll.PROPERTY_TITLE, poll.getTitle(), l(getLocale(), "pollen.error.poll.title.mandatory")); return errors; @@ -355,7 +358,7 @@ boolean choicesNotEmpty = CollectionUtils.isNotEmpty(choices); - check(errorMap, "choice", choicesNotEmpty, "need at least one choice"); + check(errorMap, "choice", choicesNotEmpty, l(getLocale(), "pollen.error.poll.choice.mandatory")); if (choicesNotEmpty) { @@ -381,15 +384,15 @@ if (PollBean.isPollFree(poll)) { - checkEmpty(errorMap, "voterList", voterLists, "can't have voterList with free poll"); + checkEmpty(errorMap, "voterList", voterLists, l(getLocale(), "pollen.error.poll.voterList.mismatch.freePoll")); } else if (PollBean.isPollRestricted(poll)) { - check(errorMap, "voterList", voterListsNotEmpty && 1 == voterLists.size(), "must have a unique voterList with a restricted poll"); + check(errorMap, "voterList", voterListsNotEmpty && 1 == voterLists.size(), l(getLocale(), "pollen.error.poll.unique.voterList.mandatory.for.restrictedPoll")); } else if (PollBean.isPollGroup(poll)) { - check(errorMap, "voterList", voterListsNotEmpty, "must have at least one voterList with a group poll"); + check(errorMap, "voterList", voterListsNotEmpty, l(getLocale(), "pollen.error.poll.voterList.mandatory.for.groupedPoll")); } Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java 2014-05-16 12:26:45 UTC (rev 3960) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenServiceSupport.java 2014-05-16 13:13:49 UTC (rev 3961) @@ -59,6 +59,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Date; +import java.util.Locale; /** * TODO @@ -99,6 +100,10 @@ return serviceContext.getPollenServiceConfig(); } + protected Locale getLocale() { + return serviceContext.getLocale(); + } + // -- Services -- // protected AuthService getAuthService() { Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties =================================================================== --- trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2014-05-16 12:26:45 UTC (rev 3960) +++ trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2014-05-16 13:13:49 UTC (rev 3961) @@ -1,15 +1,28 @@ pollen.configuration.data.directory=Directory where Pollen stores his data +pollen.configuration.defaultPollChoiceType=Default choice type used when creating a new poll pollen.configuration.defaultPollCommentVisibility=Default Poll comment visibility used when creating a new poll +pollen.configuration.defaultPollResultVisibility=Default Result vsibility used when creating a new poll pollen.configuration.defaultPollType=Default Poll type used when creating a new poll pollen.configuration.defaultPollVoteVisibility=Default Poll vote visibility used when creating a new poll pollen.configuration.defaultVoteCountingType=Default vote counting type used when creating a new poll -pollen.configuration.pollChoiceType= pollen.error.favoriteList.import.csv.already.used.email= pollen.error.favoriteList.import.csv.already.used.name= pollen.error.favoriteList.import.csv.invalid.email= pollen.error.favoriteList.import.ldap.already.used.email= pollen.error.favoriteList.import.ldap.already.used.name= pollen.error.favoriteList.import.ldap.invalid.email= +pollen.error.poll.choice.mandatory=At least a choice is mandatory +pollen.error.poll.commentVisibility.mandatory=comment visiblity is mandatory +pollen.error.poll.mismatch.freePoll=cant' have a voter list for a free poll +pollen.error.poll.pollType.mandatory=poll type is mandatory +pollen.error.poll.pollType.mandatory\ commentVisibility= +pollen.error.poll.resultVisibility.mandatory=result visibility is mandatory +pollen.error.poll.title.mandatory=title is mandatory +pollen.error.poll.unique.voterList.mandatory.for.restrictedPoll=A voter list is mandatory for a restricted poll +pollen.error.poll.voteCountingType.mandatory=vote counting type is mandatory +pollen.error.poll.voteVisibility.mandatory=vote visibility is mandatory +pollen.error.poll.voterList.mandatory.for.groupedPoll=At least one voter list ins mandatory for a grouped poll +pollen.error.poll.voterList.mismatch.freePoll= pollen.service.mail.ChoiceAddedEmail.subject=[Pollen] A choice was added in poll %s pollen.service.mail.ChoiceDeletedEmail.subject=[Pollen] A choice was deleted in poll %s pollen.service.mail.ChoiceEditedEmail.subject=[Pollen] A choice was edited in poll %s Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties =================================================================== --- trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2014-05-16 12:26:45 UTC (rev 3960) +++ trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2014-05-16 13:13:49 UTC (rev 3961) @@ -1,15 +1,27 @@ pollen.configuration.data.directory=Répertoire de données de l'application +pollen.configuration.defaultPollChoiceType=Type de choix par défaut lors de la création d'un nouveau sondage pollen.configuration.defaultPollCommentVisibility=Visibilité des commentaires par défaut lors de la création d'un nouveau sondage +pollen.configuration.defaultPollResultVisibility=Visibilité des résultats par défaut lors de la création d'un nouveau sondage pollen.configuration.defaultPollType=Type de sondage par défaut lors de la création d'un nouveau sondage pollen.configuration.defaultPollVoteVisibility=Visibilité des votes par défaut lors de la création d'un nouveau sondage pollen.configuration.defaultVoteCountingType=Type de dépouillement par défaut lors de la création d'un nouveau sondage -pollen.configuration.pollChoiceType= pollen.error.favoriteList.import.csv.already.used.email= pollen.error.favoriteList.import.csv.already.used.name= pollen.error.favoriteList.import.csv.invalid.email= pollen.error.favoriteList.import.ldap.already.used.email= pollen.error.favoriteList.import.ldap.already.used.name= pollen.error.favoriteList.import.ldap.invalid.email= +pollen.error.poll.choice.mandatory=Au moins un choix est nécessaire +pollen.error.poll.commentVisibility.mandatory=la visibilité des commentaires est obligatoire +pollen.error.poll.pollType.mandatory=le type de sondage est obligatoire +pollen.error.poll.pollType.mandatory\ commentVisibility= +pollen.error.poll.resultVisibility.mandatory=la visibilité des résultats est obligatoire +pollen.error.poll.title.mandatory=le titre du sondage est obligatoire +pollen.error.poll.unique.voterList.mandatory.for.restrictedPoll=une liste de votant est obligatoire pour un sondage restreint +pollen.error.poll.voteCountingType.mandatory=le type de vote est obligatoire +pollen.error.poll.voteVisibility.mandatory=la visiblité des votes est obligatoire +pollen.error.poll.voterList.mandatory.for.groupedPoll=Au moins une liste de votant est obligatoire pour un sondage groupé +pollen.error.poll.voterList.mismatch.freePoll=Liste de votants impossible pour un sondage libre pollen.service.mail.ChoiceAddedEmail.subject=[Pollen] Un choix a été ajouté au sondage %s pollen.service.mail.ChoiceDeletedEmail.subject=[Pollen] Un choix a été supprimé du sondage %s pollen.service.mail.ChoiceEditedEmail.subject=[Pollen] Un choix a été modifié sur le sondage %s