From a7583be0d5ac4a95b66293a897a79f53830d222c Mon Sep 17 00:00:00 2001 From: Chris Jaekl Date: Sun, 28 Dec 2014 21:49:42 -0500 Subject: [PATCH] Add translations for French and Japanese --- WEB-INF/classes/frank.properties | 3 ++ prod/frank.properties | 3 ++ prod/frank_fr.properties | 22 +++++++++++++++ prod/frank_jp.properties | 22 +++++++++++++++ prod/net/jaekl/frank/ErrorHandler.java | 32 ++++++++++++++++------ prod/net/jaekl/frank/FrankBundle.java | 3 ++ prod/net/jaekl/frank/Schedule.java | 2 +- prod/net/jaekl/frank/ViewSchedule.java | 2 ++ test/net/jaekl/frank/ErrorHandlerTest.java | 2 +- 9 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 prod/frank_fr.properties create mode 100644 prod/frank_jp.properties diff --git a/WEB-INF/classes/frank.properties b/WEB-INF/classes/frank.properties index fcfcfbf..2c5ac33 100644 --- a/WEB-INF/classes/frank.properties +++ b/WEB-INF/classes/frank.properties @@ -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 here 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.properties b/prod/frank.properties index fcfcfbf..2c5ac33 100644 --- a/prod/frank.properties +++ b/prod/frank.properties @@ -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 here 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 index 0000000..8c34140 --- /dev/null +++ b/prod/frank_fr.properties @@ -0,0 +1,22 @@ +answer.received=Réponse reçue: +data.collected=Données reçues il y a 0m 0s à {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 ici 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 index 0000000..5dda068 --- /dev/null +++ b/prod/frank_jp.properties @@ -0,0 +1,22 @@ +answer.received=\u5FDC\u7B54\uFF1A +data.collected=\u30C7\u30FC\u30BF\u3092{0}\u306B(0\u52060\u79D2\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\u3053\u3053\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 diff --git a/prod/net/jaekl/frank/ErrorHandler.java b/prod/net/jaekl/frank/ErrorHandler.java index 428925a..4b253eb 100644 --- a/prod/net/jaekl/frank/ErrorHandler.java +++ b/prod/net/jaekl/frank/ErrorHandler.java @@ -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 = ""; - 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) + ""); style.writeStyle(pw); - writeScript(pw); + writeScript(pw, bundle); pw.println(""); pw.println(""); @@ -94,7 +105,9 @@ public class ErrorHandler { // potential information leak in favour of reducing our code complexity // and the administrator's workload. - pw.println("

"); + pw.println("

"); pw.println("

"); pw.println("

");
 		
@@ -103,7 +116,10 @@ public class ErrorHandler {
 		pw.println(stackTrace);
 				
 		pw.println("
\n

\n
"); - pw.println("

Click here to return to the main page.

"); + + String returnToMainFormat = bundle.get(FrankBundle.RETURN_TO_MAIN_PAGE); + String returnToMain = MessageFormat.format(returnToMainFormat, "/"); + pw.println("

" + returnToMain + "

"); pw.println(""); } } diff --git a/prod/net/jaekl/frank/FrankBundle.java b/prod/net/jaekl/frank/FrankBundle.java index 4cac888..b85d21c 100644 --- a/prod/net/jaekl/frank/FrankBundle.java +++ b/prod/net/jaekl/frank/FrankBundle.java @@ -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"; diff --git a/prod/net/jaekl/frank/Schedule.java b/prod/net/jaekl/frank/Schedule.java index 10616b2..8cc4f84 100644 --- a/prod/net/jaekl/frank/Schedule.java +++ b/prod/net/jaekl/frank/Schedule.java @@ -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("}"); diff --git a/prod/net/jaekl/frank/ViewSchedule.java b/prod/net/jaekl/frank/ViewSchedule.java index b13258b..a2018f4 100644 --- a/prod/net/jaekl/frank/ViewSchedule.java +++ b/prod/net/jaekl/frank/ViewSchedule.java @@ -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); diff --git a/test/net/jaekl/frank/ErrorHandlerTest.java b/test/net/jaekl/frank/ErrorHandlerTest.java index 235d04f..91efd6c 100644 --- a/test/net/jaekl/frank/ErrorHandlerTest.java +++ b/test/net/jaekl/frank/ErrorHandlerTest.java @@ -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(); -- 2.39.2