UTF-8
diff --git a/site/live.html b/site/live.html
index 2fc6bd8..80e80b9 100644
--- a/site/live.html
+++ b/site/live.html
@@ -17,9 +17,9 @@
Developer Tools:
[Home]
- [M1 Bus]
- [6 Subway]
-
+ [M1 Bus | translated]
+ [6 Subway | translated]
+|
Open developer tools for more information
diff --git a/site/mta.js b/site/mta.js
index cff40ce..5da6823 100644
--- a/site/mta.js
+++ b/site/mta.js
@@ -57,6 +57,7 @@ const getLocation = async () => new Promise((res, rej) => {
* @param {*} dir direction 0 | 1
* @param {*} lat latitude
* @param {*} lon longitude
+ * @param {*} lang ISO 2-letter language code
* @returns bus
*/
const getBusByCoord = async (route, dir, lat, lon, lang) => {
@@ -72,6 +73,7 @@ const getBusByCoord = async (route, dir, lat, lon, lang) => {
/**
* @param {*} id vehicle id
+ * @param {*} lang ISO 2-letter language code
* @returns bus
*/
const getBusByID = async (id, lang) => {
@@ -84,9 +86,10 @@ const getBusByID = async (id, lang) => {
/**
* @param {*} route route code
- * @param {*} dir direction 0 | 1
+ * @param {*} dir direction 1 | 3
* @param {*} lat latitude
* @param {*} lon longitude
+ * @param {*} lang ISO 2-letter language code
* @returns bus
*/
const getSubwayByCoord = async (route, dir, lat, lon, lang) => {
@@ -102,6 +105,7 @@ const getSubwayByCoord = async (route, dir, lat, lon, lang) => {
/**
* @param {*} id vehicle id
+ * @param {*} lang ISO 2-letter language code
* @returns bus
*/
const getSubwayByID = async (id, lang) => {
diff --git a/site/tracking.js b/site/tracking.js
index 5746b93..f7fc16c 100644
--- a/site/tracking.js
+++ b/site/tracking.js
@@ -51,5 +51,7 @@ const generate = (data) => {
content += `${data.route.shortName} ${data.route.name}`;
+ content += `${JSON.stringify(data, null, 2)}
`;
+
main.innerHTML = content; // write content onto the page
}
\ No newline at end of file
diff --git a/src/main/java/dev/katsute/mis/RequestHandler.java b/src/main/java/dev/katsute/mis/RequestHandler.java
index 01daefa..f9e623c 100644
--- a/src/main/java/dev/katsute/mis/RequestHandler.java
+++ b/src/main/java/dev/katsute/mis/RequestHandler.java
@@ -169,8 +169,9 @@ public final void handle(final SimpleHttpExchange exchange){
final String desc = alert.getDescription();
a.add(new JsonBuilder()
.set("header", alert.getHeader())
+ .set("header_translated", translate(alert.getHeader().trim(), "en", lang))
.set("description", alert.getDescription().trim())
- .set("translated", translate(alert.getDescription().trim(), "en", lang))
+ .set("description_translated", translate(alert.getDescription().trim(), "en", lang))
.set("type", alert.getAlertType())
.set("effect", alert.getEffect())
.set("slow", desc.contains("slow") || desc.contains("delay"))
@@ -203,8 +204,9 @@ public final void handle(final SimpleHttpExchange exchange){
final String desc = alert.getDescription();
a.add(new JsonBuilder()
.set("header", alert.getHeader())
+ .set("header_translated", translate(alert.getHeader().trim(), "en", lang))
.set("description", alert.getDescription().trim())
- .set("translated", translate(alert.getDescription().trim(), "en", lang))
+ .set("description_translated", translate(alert.getDescription().trim(), "en", lang))
.set("type", alert.getAlertType())
.set("effect", alert.getEffect())
.set("slow", desc.contains("slow") || desc.contains("delay"))
@@ -296,8 +298,9 @@ public final void handle(final SimpleHttpExchange exchange){
final String desc = alert.getDescription().toLowerCase();
a.add(new JsonBuilder()
.set("header", alert.getHeader())
+ .set("header_translated", translate(alert.getHeader().trim(), "en", lang))
.set("description", alert.getDescription().trim())
- .set("translated", translate(alert.getDescription().trim(), "en", lang))
+ .set("description_translated", translate(alert.getDescription().trim(), "en", lang))
.set("type", alert.getAlertType())
.set("effect", alert.getEffect())
.set("slow", desc.contains("slow") || desc.contains("delay"))
@@ -333,8 +336,9 @@ public final void handle(final SimpleHttpExchange exchange){
final String desc = alert.getDescription().toLowerCase();
a.add(new JsonBuilder()
.set("header", alert.getHeader())
+ .set("header_translated", translate(alert.getHeader().trim(), "en", lang))
.set("description", alert.getDescription().trim())
- .set("translated", translate(alert.getDescription().trim(), "en", lang))
+ .set("description_translated", translate(alert.getDescription().trim(), "en", lang))
.set("type", alert.getAlertType())
.set("effect", alert.getEffect())
.set("slow", desc.contains("slow") || desc.contains("delay"))
@@ -409,11 +413,11 @@ private static String translate(final String q, final String from, final String
final Map query = new HashMap(){{
put("client", "at");
- put("dt", "t"); // sentences
+ put("dt", "t"); // translation
put("dj", "1"); // as json
- put("sl", from);
- put("tl", to);
- put("q", q);
+ put("sl", from); // source
+ put("tl", to); // target
+ put("q", q.replace("@", "at")); // query
}};
HttpURLConnection conn = null;
@@ -447,8 +451,10 @@ private static String translate(final String q, final String from, final String
final Matcher m = trans.matcher(OUT.toString());
- if(m.find())
- return m.group();
+ String str = "";
+ while(m.find())
+ str += m.group() + " ";
+ return str.trim();
}
}catch(final IOException e){
e.printStackTrace();