]> jaekl.net Git - frank.git/commitdiff
Add translations for French and Japanese
authorChris Jaekl <cejaekl@yahoo.com>
Mon, 29 Dec 2014 02:49:42 +0000 (21:49 -0500)
committerChris Jaekl <cejaekl@yahoo.com>
Mon, 29 Dec 2014 02:49:42 +0000 (21:49 -0500)
WEB-INF/classes/frank.properties
prod/frank.properties
prod/frank_fr.properties [new file with mode: 0644]
prod/frank_jp.properties [new file with mode: 0644]
prod/net/jaekl/frank/ErrorHandler.java
prod/net/jaekl/frank/FrankBundle.java
prod/net/jaekl/frank/Schedule.java
prod/net/jaekl/frank/ViewSchedule.java
test/net/jaekl/frank/ErrorHandlerTest.java

index fcfcfbf1e048d3601e61a1b8dd23a228f3ab7a97..2c5ac3344a3aa2757114eb9780c2056537caa24b 100644 (file)
@@ -6,14 +6,17 @@ eta=ETA
 frank=Frank
 gps.off=GPS off
 gps.read=GPS Read
+hide.details=Hide details
 invalid.response=Frank requested information from the OC Transpo server, but received an unexpected response.
 m=m
 maybe.server.problem=This may indicate a problem with the server that was contacted, but it is also possible that you've uncovered a bug in Frank.
 remain=Remain
 request.made=Request made:
+return.to.main.page=Click <A HREF="{0}">here</A> to return to the main page.
 route=Route
 s=s
 server.timeout=Frank requested information from the OC Transpo server, but it did not respond in a timely manner.  This probably indicates that the OC Transpo server is temporarily unavailable.  It may come back online soon; please try again in a few minutes.
+show.details=Show details
 unexpected.error=Unexpected Error
 unexpected.exception=An unexpected exception has been raised.  This probably indicates a bug in Frank.
 url.contacted=URL contacted:
index fcfcfbf1e048d3601e61a1b8dd23a228f3ab7a97..2c5ac3344a3aa2757114eb9780c2056537caa24b 100644 (file)
@@ -6,14 +6,17 @@ eta=ETA
 frank=Frank
 gps.off=GPS off
 gps.read=GPS Read
+hide.details=Hide details
 invalid.response=Frank requested information from the OC Transpo server, but received an unexpected response.
 m=m
 maybe.server.problem=This may indicate a problem with the server that was contacted, but it is also possible that you've uncovered a bug in Frank.
 remain=Remain
 request.made=Request made:
+return.to.main.page=Click <A HREF="{0}">here</A> to return to the main page.
 route=Route
 s=s
 server.timeout=Frank requested information from the OC Transpo server, but it did not respond in a timely manner.  This probably indicates that the OC Transpo server is temporarily unavailable.  It may come back online soon; please try again in a few minutes.
+show.details=Show details
 unexpected.error=Unexpected Error
 unexpected.exception=An unexpected exception has been raised.  This probably indicates a bug in Frank.
 url.contacted=URL contacted:
diff --git a/prod/frank_fr.properties b/prod/frank_fr.properties
new file mode 100644 (file)
index 0000000..8c34140
--- /dev/null
@@ -0,0 +1,22 @@
+answer.received=Réponse reçue:
+data.collected=Données reçues il y a <SPAN ID="elapsed">0m 0s</SPAN> à {0}.
+destination=Destination
+error.page=Page d'erreur
+eta=Prévue
+frank=Frank
+gps.off=Aucun signal GPS
+gps.read=Position GPS
+hide.details=Détails
+invalid.response=Frank a demandé des informations du serveur OC Transpo, mais a reçu une réponse non-valide.
+m=m
+maybe.server.problem=Cela peut indiquer un problème avec le serveur qui a été contacté, mais il est également possible que vous avez découvert un bogue dans Frank.
+remain=Dans
+request.made=Requête faite:
+return.to.main.page=Cliquez <A HREF="{0}">ici</A> pour revenir à la page principale.
+route=Route
+s=s
+server.timeout=Frank a demandé des informations du serveur d'OC Transpo, mais il n'a pas répondu en temps opportun. Le serveur d'OC Transpo probablement indisponible pour cet instant.  Il pourrait revenir bientôt en ligne; veuillez essayer de nouveau dans quelques minutes.
+show.details=Détails
+unexpected.error=Erreure inattendue
+unexpected.exception=Une exception inattendue a été rencontrée. Cela indique probablement un bogue dans Frank.
+url.contacted=URL contacté:
diff --git a/prod/frank_jp.properties b/prod/frank_jp.properties
new file mode 100644 (file)
index 0000000..5dda068
--- /dev/null
@@ -0,0 +1,22 @@
+answer.received=\u5FDC\u7B54\uFF1A
+data.collected=\u30C7\u30FC\u30BF\u3092{0}\u306B(<SPAN ID="elapsed">0\u52060\u79D2</SPAN>\u524D)\u96C6\u3081\u305F\u3002
+destination=\u76EE\u7684\u5730
+error.page=\u30A8\u30E9\u30FC\u30DA\u30FC\u30B8
+eta=\u5230\u7740\u4E88\u5B9A
+frank=\u30D5\u30E9\u30F3\u30AF
+gps.off=GPS\u306A\u3057
+gps.read=GPS
+hide.details=\u8A73\u7D30\u3092\u96A0\u3059
+invalid.response=\u30D5\u30E9\u30F3\u30AF\u306F\u3001OC\u30C4\u30E9\u30F3\u30B9\u30DD\u30FC\u306E\u30B5\u30FC\u30D0\u304B\u3089\u4E88\u671F\u305B\u306C\u56DE\u7B54\u3092\u3082\u3089\u3044\u307E\u3057\u305F\u3002
+m=\u5206
+maybe.server.problem=\u3072\u3087\u3063\u3068\u3059\u308B\u3068OC\u30C4\u30E9\u30F3\u30B9\u30DD\u30FC\u306E\u30B5\u30FC\u30D0\u306E\u554F\u984C\u304C\u3042\u308B\u304B\u3082\u3057\u308C\u306A\u3044\u3057\u3001\u30D5\u30E9\u30F3\u30AF\u306E\u554F\u984C\u304C\u3042\u308B\u304B\u3082\u3057\u308C\u306A\u3044\u3002
+remain=\u6B8B\u308A\u6642\u9593
+request.made=\u8981\u6C42\u304C\u884C\u308F\uFF1A
+return.to.main.page=\u30E1\u30A4\u30F3\u30DA\u30FC\u30B8\u306B\u623B\u308B\u306B\u306F\u3001<A HREF="{0}">\u3053\u3053</A>\u3092\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u4E0B\u3055\u3044\u3002
+route=\u30EB\u30FC\u30C8
+s=\u79D2
+server.timeout=\u30D5\u30E9\u30F3\u30AF\u306FOC\u30C4\u30E9\u30F3\u30B9\u30DD\u30FC\u306E\u30B5\u30FC\u30D0\u304B\u3089\u5FDC\u7B54\u3092\u3082\u3089\u3044\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u3042\u306E\u30B5\u30FC\u30D0\u306F\u3059\u3050\u306B\u3088\u304F\u306A\u308B\u304B\u3082\u3057\u308C\u307E\u305B\u3093\u3002\u3042\u3068\uFF15\u5206\u3001\u518D\u8A66\u884C\u3057\u3066\u4E0B\u3055\u3044\u3002
+show.details=\u8A73\u7D30\u3092\u8868\u793A
+unexpected.error=\u4E88\u671F\u3057\u306A\u3044\u30A8\u30E9\u30FC
+unexpected.exception=\u4E88\u671F\u3057\u306A\u3044\u4F8B\u5916\u3002\u3053\u308C\u306F\u304A\u305D\u3089\u304F\u3001\u30D5\u30E9\u30F3\u30AF\u306E\u30D0\u30B0\u3092\u793A\u3057\u3066\u3044\u308B\u3002
+url.contacted=URL\uFF1A
index 428925a8b5f5616101c9febfcb75ccac42f3229e..4b253ebd7a42c5b1da8e5e7a82405385c08bfcb1 100644 (file)
@@ -4,29 +4,40 @@ import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.net.SocketTimeoutException;
+import java.text.MessageFormat;
 import java.util.Locale;
 
 import net.jaekl.qd.http.InvalidResponseException;
 
 public class ErrorHandler {
-       static final String JAVASCRIPT =
+       static final String JAVASCRIPT_PART1 =
                        "<SCRIPT>\n" +
                        "  var show_hide = function() {\n" +
                        "  var theDiv = document.getElementById('details');\n" +
                        "  var theButton = document.getElementById('details_btn');\n" +
                        "  if (theDiv.style.display === 'block' || theDiv.style.display === '') {\n" +
                        "    theDiv.style.display = 'none';\n" +
-                       "  theButton.value = 'Show details';\n" +
+                       "  theButton.value = '";
+       // insert "show details" text here
+       static final String JAVASCRIPT_PART2 = "';\n" + 
                        "  }\n" +
                        "  else {\n" +
                        "    theDiv.style.display = 'block';\n" +
-                       "    theButton.value = 'Hide details';\n" +
+                       "    theButton.value = '";
+       // insert "hide details" text here
+       static final String JAVASCRIPT_PART3 = "';\n" + 
                        "  }\n" +
                        "}\n" +
                        "</SCRIPT>";
        
-       void writeScript(PrintWriter pw) {
-               pw.println(JAVASCRIPT);
+       void writeScript(PrintWriter pw, FrankBundle bundle) {
+               String javaScript = JAVASCRIPT_PART1 +  
+                                       bundle.get(FrankBundle.SHOW_DETAILS) +
+                                       JAVASCRIPT_PART2 +
+                                       bundle.get(FrankBundle.HIDE_DETAILS) +
+                                       JAVASCRIPT_PART3;
+               
+               pw.println(javaScript);
        }
        
        void explain(PrintWriter pw, Throwable t, FrankBundle bundle) {
@@ -75,7 +86,7 @@ public class ErrorHandler {
                                bundle.get(FrankBundle.ERROR_PAGE) + 
                                "</TITLE>");
                style.writeStyle(pw);
-               writeScript(pw);
+               writeScript(pw, bundle);
                pw.println("</HEAD>");
                
                pw.println("<BODY>");
@@ -94,7 +105,9 @@ public class ErrorHandler {
                // potential information leak in favour of reducing our code complexity
                // and the administrator's workload.
                
-               pw.println("<P><INPUT TYPE=\"button\" ID=\"details_btn\" VALUE=\"Show details\" ONCLICK=\"show_hide();\"/></P>");
+               pw.println("<P><INPUT TYPE=\"button\" ID=\"details_btn\" VALUE=\"" +
+                               bundle.get(FrankBundle.SHOW_DETAILS) +
+                               "\" ONCLICK=\"show_hide();\"/></P>");
                pw.println("<P>");
                pw.println("<DIV ID=\"details\" STYLE=\"display: none;\"><PRE>");
                
@@ -103,7 +116,10 @@ public class ErrorHandler {
                pw.println(stackTrace);
                                
                pw.println("</PRE>\n</P>\n</DIV>");
-               pw.println("<P>Click <A HREF=\"/\">here</A> to return to the main page.</P>");
+               
+               String returnToMainFormat = bundle.get(FrankBundle.RETURN_TO_MAIN_PAGE);
+               String returnToMain = MessageFormat.format(returnToMainFormat, "/");
+               pw.println("<P>" + returnToMain + "</P>");
                pw.println("</BODY></HTML>");
        }
 }
index 4cac888552c8f878dac2d92da1e2085cf50c0506..b85d21cb5a8e8393d728238e7e1f765c4a529e3c 100644 (file)
@@ -16,14 +16,17 @@ public class FrankBundle {
        public static final String FRANK = "frank";
        public static final String GPS_OFF = "gps.off";
        public static final String GPS_READ = "gps.read";
+       public static final String HIDE_DETAILS = "hide.details";
        public static final String INVALID_RESPONSE = "invalid.response";
        public static final String MAYBE_SERVER_PROBLEM = "maybe.server.problem";
        public static final String MINUTES = "m";       // suffix (abbreviated) for minutes
        public static final String REMAIN = "remain";
        public static final String REQUEST_MADE = "request.made";
+       public static final String RETURN_TO_MAIN_PAGE = "return.to.main.page";
        public static final String ROUTE = "route";
        public static final String SECONDS = "s";
        public static final String SERVER_TIMEOUT = "server.timeout";
+       public static final String SHOW_DETAILS = "show.details";
        public static final String UNEXPECTED_ERROR = "unexpected.error";
        public static final String UNEXPECTED_EXCEPTION = "unexpected.exception";
        public static final String URL_CONTACTED = "url.contacted";
index 10616b23007608c5802fb4989ee61dbf8408295e..8cc4f846124a5a1b628c0d011e3f6069d80ff5d2 100644 (file)
@@ -62,7 +62,7 @@ public class Schedule {
            pw.println("    if (remain_delta <= 0) {");
            pw.println("      element.innerHTML = \"----\";");
            pw.println("    } else {");
-           pw.println("      element.innerHTML = (Math.floor(remain_delta / 60)) + \"" + trans(min) + "\";");
+           pw.println("      element.innerHTML = (Math.floor(remain_delta / 60)) + \"" + min + "\";");
            pw.println("    }");
            pw.println("  }");
            pw.println("}");
index b13258b3a8ce66227652ee6880886823601528ce..a2018f48707bde248b536536d068cb69925d038d 100644 (file)
@@ -21,6 +21,7 @@ public class ViewSchedule extends HttpServlet {
        static final String STOP = "stop";
        static final String ROUTE = "route";
        static final String LANG = "lang";
+       static final String UTF_8 = "UTF-8";
        
        ErrorHandler m_errorHandler;
        
@@ -65,6 +66,7 @@ public class ViewSchedule extends HttpServlet {
        throws ServletException, IOException
        {
                res.setContentType("text/html");
+               res.setCharacterEncoding("utf8");       // Seems to be necessary when running in Japanese
                PrintWriter pw = res.getWriter();
                
                Locale locale = getLocale(req);
index 235d04fb3277b1984b9bc16c8efcee16340265d2..91efd6c14dac1140a3046375baf7022a034c5630 100644 (file)
@@ -95,7 +95,7 @@ public class ErrorHandlerTest {
                        FrankBundle bundle = FrankBundle.getInst(locale);
                        
                        m_baos.reset();
-                       eh.writeErrorPage(m_pw, fe,  Locale.CANADA);
+                       eh.writeErrorPage(m_pw, fe,  locale);
                        m_pw.flush();
                        
                        String actual = m_baos.toString();