diff options
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r-- | src/main/java/com/juick/www/controllers/Site.java | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/main/java/com/juick/www/controllers/Site.java b/src/main/java/com/juick/www/controllers/Site.java index 4aa82f1a..0cc0abfe 100644 --- a/src/main/java/com/juick/www/controllers/Site.java +++ b/src/main/java/com/juick/www/controllers/Site.java @@ -30,12 +30,17 @@ import com.juick.util.MessageUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.text.StringEscapeUtils; +import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.CookieValue; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; @@ -44,7 +49,9 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Optional; +import java.util.ResourceBundle; import java.util.stream.Collectors; /** @@ -106,33 +113,36 @@ public class Site { String title; List<Integer> mids; + Locale locale = LocaleContextHolder.getLocale(); + if (paramSearch != null) { - title = "Поиск: " + StringEscapeUtils.escapeHtml4(paramSearch); + String searchTitle = ResourceBundle.getBundle("messages", locale).getString("title.search"); + title = searchTitle + StringEscapeUtils.escapeHtml4(paramSearch); mids = messagesService.getSearch(visitor, WebUtils.encodeSphinx(paramSearch), page); } else if (paramShow == null) { - title = "Обсуждения"; + title = ResourceBundle.getBundle("messages", locale).getString("link.discuss"); mids = messagesService.getDiscussions(visitor.getUid(), paramTo); } else if (paramShow.equals("top")) { - title = "Популярные"; + title = ResourceBundle.getBundle("messages", locale).getString("link.popular"); mids = messagesService.getPopular(visitor.getUid(), paramBefore); model.addAttribute("discover", true); } else if (paramShow.equals("my") && !visitor.isAnonymous()) { - title = "Моя лента"; + title = ResourceBundle.getBundle("messages", locale).getString("link.my"); mids = messagesService.getMyFeed(visitor.getUid(), paramBefore, true); } else if (paramShow.equals("private") && !visitor.isAnonymous()) { - title = "Приватные"; + title = ResourceBundle.getBundle("messages", locale).getString("link.privateMessages"); mids = messagesService.getPrivate(visitor.getUid(), paramBefore); } else if (paramShow.equals("discuss")) { return "redirect:/"; } else if (paramShow.equals("recommended") && !visitor.isAnonymous()) { - title = "Рекомендации"; + title = ResourceBundle.getBundle("messages", locale).getString("link.recommended"); mids = messagesService.getRecommended(visitor.getUid(), paramBefore); } else if (paramShow.equals("photos")) { - title = "Фотографии"; + title = ResourceBundle.getBundle("messages", locale).getString("link.withPhotos"); mids = messagesService.getPhotos(visitor.getUid(), paramBefore); model.addAttribute("discover", true); } else if (paramShow.equals("all")) { - title = "Все сообщения"; + title = ResourceBundle.getBundle("messages", locale).getString("link.allMessages"); mids = messagesService.getAll(visitor.getUid(), paramBefore); model.addAttribute("discover", true); } else { |