Skip to content

Add languages #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
language: java
jdk:
- oraclejdk8
- openjdk8
- oraclejdk9
language: java
2 changes: 2 additions & 0 deletions src/main/java/hello/GreetingController.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ public class GreetingController {

@RequestMapping("/greeting")
public String greeting(@RequestParam(value="name", required=false, defaultValue="World") String name,
@RequestParam(value="lang", required=false, defaultValue="en") String lang,
Model model) {
model.addAttribute("hello", greetingTranslator.sayHelloIn(lang));
model.addAttribute("name", name);
return "greeting";
}
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/hello/GreetingTranslator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package hello;

public class GreetingTranslator {

public String sayHelloIn(String lang) {
String hello;
if ("en".equals(lang)) {
hello = "hello";
} else if ("es".equals(lang)) {
hello = "hola";
} else {
hello = "no hablo tu idioma";
}
}

}
2 changes: 1 addition & 1 deletion src/main/resources/templates/greeting.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p th:text="'Hello, ' + ${name} + '!'" />
<p th:text="${hello} + ', ' + ${name} + '!'" />
</body>
</html>