Skip to content

Commit

Permalink
Fixing javadoc and change pom version to SNAPSHOT
Browse files Browse the repository at this point in the history
  • Loading branch information
pwener committed May 8, 2017
1 parent 88a2a8c commit 79bd9b8
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 14 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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<br/>
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<br/>
http://blog.caelum.com.br/i18n-internacionalizacao-com-jstl/

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.github.projecturutau</groupId>
<artifactId>vraptor-flash-i18n</artifactId>
<version>0.01</version>
<version>0.01-SNAPSHOT</version>
<packaging>jar</packaging>
<name>vraptor-flash-i18n</name>
<url>https://github.com/ProjectUrutau/vraptor-flash-i18n</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ 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);

/**
* Condition to shows the message
*
* @param condition is to evaluate if message should be included
* @return self object
*/
public FlashMessage when(Boolean condition);
}
Original file line number Diff line number Diff line change
@@ -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> Controller redirectTo(Class<Controller> controller);
public <Controller> Controller redirectTo(Class<Controller> 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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 79bd9b8

Please sign in to comment.