Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
847 additions
and
1,120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
logs | ||
project/project | ||
project/target | ||
target | ||
tmp | ||
.history | ||
dist | ||
/.idea | ||
/*.iml | ||
/out | ||
/.idea_modules | ||
/.classpath | ||
/.project | ||
/RUNNING_PID | ||
/.settings |
38 changes: 30 additions & 8 deletions
38
test-application/app/controllers/LocalizedApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,53 @@ | ||
package controllers; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
import static play.data.Form.form; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import play.data.DynamicForm; | ||
import play.i18n.Lang; | ||
import play.i18n.Messages; | ||
import play.mvc.Controller; | ||
import play.mvc.Result; | ||
|
||
/** | ||
* @author huljas | ||
*/ | ||
public class LocalizedApplication extends Controller { | ||
|
||
public static void hello(String name) { | ||
public static List<String> getLangs() { | ||
List<String> list = new ArrayList<>(); | ||
for (Lang i : Lang.availables()) { | ||
list.add(i.code()); | ||
} | ||
|
||
return list; | ||
} | ||
|
||
public static Result hello() { | ||
DynamicForm f = form().bindFromRequest(); | ||
String name = f.get("name"); | ||
if (StringUtils.isBlank(name)) { | ||
name = Messages.get("you"); | ||
} | ||
String hello = Messages.get("hello.type.normal", name); | ||
render(hello); | ||
return ok(views.html.hello.render(hello)); | ||
} | ||
|
||
public static void helloWithType(String name, String type) { | ||
public static Result helloWithType() { | ||
DynamicForm f = form().bindFromRequest(); | ||
String name = f.get("name"); | ||
String type = f.get("type"); | ||
String hello = Messages.get("hello.type." + type, name); | ||
render("@hello", hello); | ||
return ok(views.html.hello.render(hello)); | ||
} | ||
|
||
public static void setLang(String lang) { | ||
Lang.change(lang); | ||
hello(null); | ||
public static Result setLang(String lang) { | ||
changeLang(lang); | ||
return hello(); | ||
} | ||
|
||
} |
33 changes: 0 additions & 33 deletions
33
test-application/app/views/LocalizedApplication/hello.html
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.