aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/juick/http/www/PageTemplates.java
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2014-01-31 21:44:51 +0700
committerGravatar Ugnich Anton2014-01-31 21:44:51 +0700
commitab78d170650106d1d1113282598b6d8270ef2e76 (patch)
tree4ee839ab0d00cc4cec8ec55e94929cedd782302f /src/java/com/juick/http/www/PageTemplates.java
parentcd7016bd09dd1fc21f375765d5cc510a1ad0656b (diff)
Russian as default
Diffstat (limited to 'src/java/com/juick/http/www/PageTemplates.java')
-rw-r--r--src/java/com/juick/http/www/PageTemplates.java90
1 files changed, 60 insertions, 30 deletions
diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java
index 462fdf31..c8d47245 100644
--- a/src/java/com/juick/http/www/PageTemplates.java
+++ b/src/java/com/juick/http/www/PageTemplates.java
@@ -31,8 +31,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
-import java.util.Locale;
-import java.util.ResourceBundle;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
@@ -69,7 +67,7 @@ public class PageTemplates {
out.println("<body>");
}
- public static void pageNavigation(PrintWriter out, Locale loc, com.juick.User visitor, String search) {
+ public static void pageNavigation(PrintWriter out, com.juick.User visitor, String search) {
out.println("<header>");
out.println(" <div id=\"logo\"><a href=\"/\">Juick</a></div>");
out.println(" <nav id=\"global\"><ul>");
@@ -138,7 +136,7 @@ public class PageTemplates {
out.println("</script>");
}
- public static void pageHomeColumn(PrintWriter out, Connection sql, com.juick.User visitor, Locale locale) {
+ public static void pageHomeColumn(PrintWriter out, Connection sql, com.juick.User visitor) {
if (tagsHTML == null) {
tagsHTML = PageTemplates.getPopularTags(sql, 60);
}
@@ -197,14 +195,13 @@ public class PageTemplates {
return ret;
}
- public static void pageDialogTemplate(PrintWriter out, Locale locale) {
- ResourceBundle rb = ResourceBundle.getBundle("Global", locale);
+ public static void pageDialogTemplate(PrintWriter out) {
out.println("<div id=\"dialogb\" onclick=\"$('#dialogb').hide();$('#dialogw').hide()\"></div>");
- out.println("<div id=\"dialogw\">" + rb.getString("(Dialog) Link to message") + ":");
+ out.println("<div id=\"dialogw\">Ссылка на сообщение:");
out.println("<div id=\"dialogl\" onclick=\"$(this).selectText()\"></div>");
- out.println(rb.getString("(Dialog) Message number") + ":");
+ out.println("Номер сообщения:");
out.println("<div id=\"dialogn\" onclick=\"$(this).selectText()\"></div>");
- out.println(rb.getString("(Dialog) Share") + ":");
+ out.println("Поделиться:");
out.println("<ul>");
out.println(" <li><a id=\"sharefb\"></a></li>");
out.println(" <li><a id=\"sharetw\"></a></li>");
@@ -214,7 +211,7 @@ public class PageTemplates {
out.println("</div>");
}
- public static void pageFooter(HttpServletRequest request, PrintWriter out, Locale loc, com.juick.User visitor, boolean sapeon) {
+ public static void pageFooter(HttpServletRequest request, PrintWriter out, com.juick.User visitor, boolean sapeon) {
out.println("<div id=\"fwrapper\"><div id=\"footer\">");
out.println(" <div id=\"footer-right\"><a href=\"/settings\" rel=\"nofollow\">Настройки</a> &#183; <a href=\"/help/ru/contacts\" rel=\"nofollow\">Контакты</a> &#183; <a href=\"/help/\" rel=\"nofollow\">Справка</a> &#183; <a href=\"/help/ru/adv\" rel=\"nofollow\">Реклама</a></div>");
out.print(" <div id=\"footer-left\">juick.com &copy; 2008-2014");
@@ -253,17 +250,44 @@ public class PageTemplates {
return ret;
}
- public static String formatDate(int minsago, String fulldate, Locale loc) {
- if (minsago < 1) {
- return "now";
- } else if (minsago < 60) {
- return minsago + " minute" + ((minsago % 10 == 1) ? "" : "s") + " ago";
- } else if (minsago < 1440) {
- int hours = (minsago / 60);
- return hours + " hour" + ((hours % 10 == 1) ? "" : "s") + " ago";
- } else if (minsago < 20160) {
- int days = (minsago / 1440);
- return days + " day" + ((days % 10 == 1) ? "" : "s") + " ago";
+ public static String formatDate(int minutes, String fulldate) {
+ if (minutes < 1) {
+ return "сейчас";
+ } else if (minutes < 60) {
+ String unit;
+ int ld = minutes % 10;
+ if ((minutes < 10 || minutes > 20) && ld == 1) {
+ unit = "минуту";
+ } else if ((minutes < 10 || minutes > 20) && ld > 1 && ld < 5) {
+ unit = "минуты";
+ } else {
+ unit = "минут";
+ }
+ return minutes + " " + unit + " назад";
+ } else if (minutes < 1440) {
+ int hours = (minutes / 60);
+ String unit;
+ int ld = hours % 10;
+ if ((hours < 10 || hours > 20) && ld == 1) {
+ unit = "час";
+ } else if ((hours < 10 || hours > 20) && ld > 1 && ld < 5) {
+ unit = "часа";
+ } else {
+ unit = "часов";
+ }
+ return hours + " " + unit + " назад";
+ } else if (minutes < 20160) {
+ int days = (minutes / 1440);
+ String unit;
+ int ld = days % 10;
+ if ((days < 10 || days > 20) && ld == 1) {
+ unit = "день";
+ } else if ((days < 10 || days > 20) && ld > 1 && ld < 5) {
+ unit = "дня";
+ } else {
+ unit = "дней";
+ }
+ return days + " " + unit + " назад";
} else {
try {
Date pDate = sdfSQL.parse(fulldate);
@@ -294,8 +318,16 @@ public class PageTemplates {
return "";
}
- public static String formatReplies(int replies, Locale loc) {
- return replies + " repl" + (replies % 10 == 1 ? "y" : "ies");
+ public static String formatReplies(int replies) {
+ int ld = replies % 10;
+ int lh = replies % 100;
+ if ((lh < 10 || lh > 20) && ld == 1) {
+ return replies + " ответ";
+ } else if ((lh < 10 || lh > 20) && ld > 1 && ld < 5) {
+ return replies + " ответа";
+ } else {
+ return replies + " ответов";
+ }
}
private static Pattern regexLinks2 = Pattern.compile("((?<=\\s)|(?<=\\A))([\\[\\{]|&lt;)((?:ht|f)tps?://(?:www\\.)?([^\\/\\s\\\"\\)\\!]+)/?(?:[^\\]\\}](?<!&gt;))*)([\\]\\}]|&gt;)");
@@ -386,9 +418,7 @@ public class PageTemplates {
return msg;
}
- public static void printMessages(PrintWriter out, Connection sql, com.juick.User user, ArrayList<Integer> mids, com.juick.User visitor, Locale locale, int YandexID, int ad_mid) {
- ResourceBundle rb = ResourceBundle.getBundle("Global", locale);
-
+ public static void printMessages(PrintWriter out, Connection sql, com.juick.User user, ArrayList<Integer> mids, com.juick.User visitor, int YandexID, int ad_mid) {
ArrayList<com.juick.Message> msgs = MessagesQueries.getMessages(sql, mids);
for (int i = 0; i < msgs.size(); i++) {
@@ -478,9 +508,9 @@ public class PageTemplates {
out.println(" <div class=\"msg-cont\">");
out.println(" <div class=\"msg-menu\"><a href=\"#\" onclick=\"showMessageLinksDialog(" + msg.MID + "); return false\"></a></div>");
out.println(" <div class=\"msg-header\"><a href=\"/" + msg.User.UName + "/\">@" + msg.User.UName + "</a>:" + tags + "</div>");
- out.print(" <div class=\"msg-ts\"><a href=\"/" + msg.User.UName + "/" + msg.MID + "\" title=\"" + msg.TimestampString + " GMT\">" + formatDate(msg.TimeAgo, msg.TimestampString, locale) + "</a>");
+ out.print(" <div class=\"msg-ts\"><a href=\"/" + msg.User.UName + "/" + msg.MID + "\" title=\"" + msg.TimestampString + " GMT\">" + formatDate(msg.TimeAgo, msg.TimestampString) + "</a>");
if (msg.MID == ad_mid) {
- out.print(" &#183; <a href=\"/help/ru/adv\">" + rb.getString("Sponsored") + "</a>");
+ out.print(" &#183; <a href=\"/help/ru/adv\">Реклама</a>");
}
out.println("</div>");
@@ -494,12 +524,12 @@ public class PageTemplates {
if (visitor != null && (msg.ReadOnly == false || visitor.UID == msg.User.UID)) {
out.println(" <form action=\"/post\" method=\"POST\" enctype=\"multipart/form-data\"><input type=\"hidden\" name=\"mid\" value=\"" + msg.MID + "\"/>");
- out.println(" <div class=\"msg-comment\"><div class=\"ta-wrapper\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"" + rb.getString("Add a comment") + "\" onkeypress=\"postformListener(this.form,event)\"></textarea></div></div>");
+ out.println(" <div class=\"msg-comment\"><div class=\"ta-wrapper\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"Написать комментарий\" onkeypress=\"postformListener(this.form,event)\"></textarea></div></div>");
out.println(" </form>");
}
if (msg.Replies > 0) {
String repliesby = (msg.RepliesBy != null) ? msg.RepliesBy : "...";
- out.println(" <div class=\"msg-comments\"><a href=\"/" + msg.User.UName + "/" + msg.MID + "\">" + formatReplies(msg.Replies, locale) + "</a> " + rb.getString("(replies) by") + " " + repliesby + "</div>");
+ out.println(" <div class=\"msg-comments\"><a href=\"/" + msg.User.UName + "/" + msg.MID + "\">" + formatReplies(msg.Replies) + "</a> от " + repliesby + "</div>");
}
out.println(" </div>");
out.println(" </li>");