From 79bd9b8cfe7e50e5f5585499621a1b72f1f1f97b Mon Sep 17 00:00:00 2001 From: pwener Date: Mon, 8 May 2017 19:33:59 -0300 Subject: [PATCH] Fixing javadoc and change pom version to SNAPSHOT --- README.md | 40 +++++++++++++++++++ pom.xml | 2 +- .../vraptor/handler/FlashError.java | 2 +- .../vraptor/handler/FlashMessage.java | 5 ++- .../vraptor/handler/Redirector.java | 11 +++-- .../vraptor/handler/Screened.java | 3 +- .../handler/impl/MethodExecutedObserver.java | 2 +- .../vraptor/i18n/I18nMessageCreator.java | 4 +- 8 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..26bfad3 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# Vraptor flash i18n + +Write your i18n messages with a fluent and easy mode in Vraptor. + +The common way to add a message(without translate) into vraptor is: + +```java + result.include("mensagem", "Vraptor é incrível").redirectTo(this).method(); +``` + +There is some ways to translate this. Basically what this pluggin makes is facilitate within standardized way of internationalize your messages, throught the method chain we could use just: + +```java + flash.use("message").toShow("vraptor_awesome").redirectingTo(this).method(); +``` + +You could use a conditional method to evaluates if a message should be showed up: + +```java + flash.when(true).use("message").toShow("vraptor_awesome").redirectingTo(this).method(); +``` + +## Configure your i18n + +This pluggin works with I18nMessage native Vraptor class. So to create a language support, you should put into (WEB-INF/classes) or (src/main/resources/) files like: + +messages.properties
+messages_en_US.properties + +Each with the logic: +```text +# key = translated_message +vraptor_awesome = Vraptor is awesome! +``` + +Veja também: + +http://www.vraptor.org/pt/docs/guia-de-10-minutos/#arquivo-de-mensagens
+http://blog.caelum.com.br/i18n-internacionalizacao-com-jstl/ + diff --git a/pom.xml b/pom.xml index dc169f9..f2d572d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.github.projecturutau vraptor-flash-i18n - 0.01 + 0.01-SNAPSHOT jar vraptor-flash-i18n https://github.com/ProjectUrutau/vraptor-flash-i18n diff --git a/src/main/java/io/github/projecturutau/vraptor/handler/FlashError.java b/src/main/java/io/github/projecturutau/vraptor/handler/FlashError.java index ea62d19..dba89a3 100644 --- a/src/main/java/io/github/projecturutau/vraptor/handler/FlashError.java +++ b/src/main/java/io/github/projecturutau/vraptor/handler/FlashError.java @@ -13,7 +13,7 @@ public interface FlashError { * Put a message into {@link Validator#getErrors()} * * @param message to be translated - * @return + * @return {@link Validator} */ public Validator add(String message); diff --git a/src/main/java/io/github/projecturutau/vraptor/handler/FlashMessage.java b/src/main/java/io/github/projecturutau/vraptor/handler/FlashMessage.java index fc237ce..68415aa 100644 --- a/src/main/java/io/github/projecturutau/vraptor/handler/FlashMessage.java +++ b/src/main/java/io/github/projecturutau/vraptor/handler/FlashMessage.java @@ -4,8 +4,8 @@ public interface FlashMessage { /** * Mark a context to put a message * - * @param context some place into views - * @return this Handler to calls {@link #show(String)} by chain method + * @param category refers to some place into views + * @return this Handler to calls {@link io.github.projecturutau.vraptor.handler.Screened#toShow(String)} by chain method */ public Screened use(String category); @@ -13,6 +13,7 @@ public interface FlashMessage { * Condition to shows the message * * @param condition is to evaluate if message should be included + * @return self object */ public FlashMessage when(Boolean condition); } \ No newline at end of file diff --git a/src/main/java/io/github/projecturutau/vraptor/handler/Redirector.java b/src/main/java/io/github/projecturutau/vraptor/handler/Redirector.java index d9c4541..23de62b 100644 --- a/src/main/java/io/github/projecturutau/vraptor/handler/Redirector.java +++ b/src/main/java/io/github/projecturutau/vraptor/handler/Redirector.java @@ -1,23 +1,22 @@ package io.github.projecturutau.vraptor.handler; import br.com.caelum.vraptor.validator.Validator; -import br.com.caelum.vraptor.view.Results; public interface Redirector { /** * Uses {@link Validator#onErrorRedirectTo(Class)} to redirects to another action * * @param controller contains action that will be called - * @return {@link br.com.caelum.vraptor.Controller} to calls some action + * @return Controller to calls some action */ - Controller redirectTo(Class controller); + public Controller redirectTo(Class controller); - void sendJSON(); + public void sendJSON(); /** * Stay on the current page, this is the default behavior to POST and PUT methods * - * @see {@link Results#referer()} + * {@link br.com.caelum.vraptor.view.Results#referer()} */ - void stay(); + public void stay(); } diff --git a/src/main/java/io/github/projecturutau/vraptor/handler/Screened.java b/src/main/java/io/github/projecturutau/vraptor/handler/Screened.java index 63d38af..a2ed388 100644 --- a/src/main/java/io/github/projecturutau/vraptor/handler/Screened.java +++ b/src/main/java/io/github/projecturutau/vraptor/handler/Screened.java @@ -2,9 +2,10 @@ public interface Screened { /** - * Writes the user message after invoke a {@link #when(Boolean)} method + * Writes the user message after invoke a {see FlashError#when(Boolean)} method * * @param message Error message + * @return {@link Redirector} that decide where go */ public Redirector toShow(String message); } diff --git a/src/main/java/io/github/projecturutau/vraptor/handler/impl/MethodExecutedObserver.java b/src/main/java/io/github/projecturutau/vraptor/handler/impl/MethodExecutedObserver.java index c6a5581..535b3c1 100644 --- a/src/main/java/io/github/projecturutau/vraptor/handler/impl/MethodExecutedObserver.java +++ b/src/main/java/io/github/projecturutau/vraptor/handler/impl/MethodExecutedObserver.java @@ -33,7 +33,7 @@ public MethodExecutedObserver(HttpServletRequest request, Result result, Redirec * When method has been executed if result has not been decided, * should be call {@link Redirector#stay()} * - * @param method + * @param method Vraptor gives the method listened in this observer */ public void stay(@Observes MethodExecuted method) { // Stay in same page diff --git a/src/main/java/io/github/projecturutau/vraptor/i18n/I18nMessageCreator.java b/src/main/java/io/github/projecturutau/vraptor/i18n/I18nMessageCreator.java index 26cea97..21a1bcc 100644 --- a/src/main/java/io/github/projecturutau/vraptor/i18n/I18nMessageCreator.java +++ b/src/main/java/io/github/projecturutau/vraptor/i18n/I18nMessageCreator.java @@ -16,8 +16,8 @@ public class I18nMessageCreator { private String message; /** - * Creates a new message internationalized. See {@link I18nMessage} and - * {@link Message} + * Creates a new message internationalized. @see br.com.caelum.vraptor.validator.I18nMessage and + * @see br.com.caelum.vraptor.validator.Message * * @param category * of message