Skip to content

Commit fc19801

Browse files
committed
Interface também disponível em inglês e espanhol
1 parent deba5d0 commit fc19801

File tree

10 files changed

+156
-92
lines changed

10 files changed

+156
-92
lines changed

deploy/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

deploy/service-worker.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/index.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="pt-br">
33
<head>
44
<meta charset="utf-8">
5-
<title>Horários</title>
5+
<title>VLT Carioca – Horários</title>
66
<meta name="description" content="Horário dos próximos trens do VLT Carioca">
77
<link rel="stylesheet" href="vlt.css">
88
<meta name="mobile-web-app-capable" content="yes">
@@ -45,17 +45,21 @@ <h1><span class="station-name"></span><span class="placeholder"></span></h1><i c
4545
</div>
4646
</div>
4747
<div class="panel-footer">
48+
<div class="network">
49+
<div class="icon material-icons"></div>
50+
<div class="text"></div>
51+
</div>
4852
<div class="status -mode--collapsed">
4953
<div class="icon material-icons"></div>
5054
<div class="text"></div>
5155
</div>
52-
<div class="network"></div>
5356
</div>
5457
</div>
5558
</div>
5659
</body>
5760
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha384-vk5WoKIaW/vJyUAd9n/wmopsmNhiy+L2Z+SBxGYnUkunIxVxAv/UtMOhba/xskxh" crossorigin="anonymous"></script>
5861
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js" integrity="sha384-fYxN7HsDOBRo1wT/NSZ0LkoNlcXvpDpFy6WzB42LxuKAX7sBwgo7vuins+E1HCaw" crossorigin="anonymous"></script>
5962
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/pt-br.js" integrity="sha384-rMnAUuld2UG2Cd+wqmGwCPZGHemXzhyJss9LFN3y2b8FNsBOrGEHpbeUFMiP1rx+" crossorigin="anonymous"></script>
63+
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/es.js" integrity="sha384-1qAUeyS6EIOskM+UWGhJh3qUqepgvqXZ12P6NiY/UiUeeaHSLMAKMyRpJ3gd4vTG" crossorigin="anonymous"></script>
6064
<script src="vlt.js"></script>
6165
</html>

public/service-worker.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const precache = () => {
2222
"/icon.png",
2323
"https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js",
2424
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js",
25-
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/pt-br.js"
25+
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/pt-br.js",
26+
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/es.js"
2627
]));
2728
};
2829

public/vlt.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/vlt.js

Lines changed: 63 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/assets/service-worker.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const precache = () => {
2222
"/icon.png",
2323
"https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js",
2424
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js",
25-
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/pt-br.js"
25+
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/pt-br.js",
26+
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/es.js"
2627
]));
2728
};
2829

source/html/vlt.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ html(lang="pt-br")
7979
script(src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js", integrity="sha384-vk5WoKIaW/vJyUAd9n/wmopsmNhiy+L2Z+SBxGYnUkunIxVxAv/UtMOhba/xskxh", crossorigin="anonymous")
8080
script(src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js", integrity="sha384-fYxN7HsDOBRo1wT/NSZ0LkoNlcXvpDpFy6WzB42LxuKAX7sBwgo7vuins+E1HCaw", crossorigin="anonymous")
8181
script(src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/pt-br.js", integrity="sha384-rMnAUuld2UG2Cd+wqmGwCPZGHemXzhyJss9LFN3y2b8FNsBOrGEHpbeUFMiP1rx+", crossorigin="anonymous")
82-
//- script(src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/es.js", integrity="sha384-1qAUeyS6EIOskM+UWGhJh3qUqepgvqXZ12P6NiY/UiUeeaHSLMAKMyRpJ3gd4vTG", crossorigin="anonymous")
82+
script(src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/es.js", integrity="sha384-1qAUeyS6EIOskM+UWGhJh3qUqepgvqXZ12P6NiY/UiUeeaHSLMAKMyRpJ3gd4vTG", crossorigin="anonymous")
8383

8484
if (env === "development")
8585
script(src="vlt.js", inline=inline)

source/js/L10n.js

Lines changed: 77 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,84 @@
22
// localization ////////////////////////////////////////////////////////////////////////////////////
33
////////////////////////////////////////////////////////////////////////////////////////////////////
44

5-
// const language = (navigator.language ? navigator.language.substr(0, 2) : "pt");
6-
const language = "pt";
5+
// Ajustes nas traduções do Moment
6+
moment.updateLocale("pt-br", {
7+
"relativeTime": {
8+
"past": "%s atrás"
9+
}
10+
});
711

8-
// if (language === "pt") {
9-
moment.locale("pt-br");
10-
// } else {
11-
// moment.locale(language);
12-
// }
12+
// Define o idioma
13+
const default_language = "en";
14+
const available_languages = ["pt", "en", "es"];
15+
const user_language = (navigator.language ? navigator.language.substr(0, 2) : default_language);
1316

14-
const L10n = {
15-
"pt": {
16-
"next-departures": "Próximos trens",
17-
"real-time": "Tempo real",
18-
"are-you-at": "Está em",
19-
"direction": "Sentido",
20-
"now": "Agora",
21-
"train": "Trem",
22-
"line": "Linha",
23-
"updated": "Atualizado",
24-
"out-of-operation": "Fora de operação",
25-
"operation-hours": "O VLT Carioca circula<br> todos os dias das 6h à 0h",
26-
"ago": "atrás",
27-
"stations": "Estações",
28-
"find-nearest-station": "Localizar estação mais próxima",
29-
"auto-theme": "Tema automático",
30-
"light-theme": "Tema claro",
31-
"dark-theme": "Tema escuro",
32-
"offline": "Sem conexão",
33-
"status-ok": "Operação normal"
34-
}
35-
// "en": {
36-
// "next-departures": "Next trains",
37-
// "real-time": "Real Time",
38-
// "are-you-at": "Are you at",
39-
// "direction": "Direction",
40-
// "now": "Now",
41-
// "train": "Train",
42-
// "line": "Line",
43-
// "updated": "Updated",
44-
// "out-of-operation": "Service closed",
45-
// "operation-hours": "VLT Carioca runs<br> daily from 6am to 12am",
46-
// "ago": "ago",
47-
// "stations": "Stations",
48-
// "find-nearest-station": "Find your nearest station",
49-
// "auto-theme": "Auto theme",
50-
// "light-theme": "Light theme",
51-
// "dark-theme": "Dark theme",
52-
// "offline": "Offline",
53-
// "status-ok": "Good service"
54-
// },
55-
// "es": {
17+
const language = available_languages.includes(user_language) ? user_language : default_language;
18+
// const language = "pt";
19+
20+
if (language === "pt") {
21+
moment.locale("pt-br");
22+
} else {
23+
moment.locale(language);
24+
}
5625

57-
// }
26+
// Traduções
27+
const L10n = {
28+
"pt": {
29+
"next-departures": "Próximos trens",
30+
"real-time": "Tempo real",
31+
"are-you-at": "Está em",
32+
"direction": "Sentido",
33+
"now": "Agora",
34+
"train": "Trem",
35+
"line": "Linha",
36+
"updated": "Atualizado",
37+
"out-of-operation": "Fora de operação",
38+
"operation-hours": "O VLT Carioca circula<br> todos os dias das 6h à 0h",
39+
"stations": "Estações",
40+
"find-nearest-station": "Localizar estação mais próxima",
41+
"auto-theme": "Tema automático",
42+
"light-theme": "Tema claro",
43+
"dark-theme": "Tema escuro",
44+
"offline": "Sem conexão",
45+
"status-ok": "Operação normal",
46+
},
47+
"en": {
48+
"next-departures": "Next trains",
49+
"real-time": "Real time",
50+
"are-you-at": "Are you at",
51+
"direction": "Direction",
52+
"now": "Now",
53+
"train": "Train",
54+
"line": "Line",
55+
"updated": "Updated",
56+
"out-of-operation": "Service closed",
57+
"operation-hours": "VLT Carioca runs<br> daily from 6am to 12am",
58+
"stations": "Stations",
59+
"find-nearest-station": "Find nearest station",
60+
"auto-theme": "Auto theme",
61+
"light-theme": "Light theme",
62+
"dark-theme": "Dark theme",
63+
"offline": "Offline",
64+
"status-ok": "Normal traffic",
65+
},
66+
"es": {
67+
"next-departures": "Próximos trenes",
68+
"real-time": "Tiempo real",
69+
"are-you-at": "¿Estás en",
70+
"direction": "Dirección",
71+
"now": "Ahora",
72+
"train": "Tren",
73+
"line": "Línea",
74+
"updated": "Actualizado",
75+
"out-of-operation": "Servicio cerrado",
76+
"operation-hours": "VLT Carioca funciona<br> todos los días de 06:00 a 00:00",
77+
"stations": "Estaciones",
78+
"find-nearest-station": "Encontrar la estación más cercana",
79+
"auto-theme": "Tema automático",
80+
"light-theme": "Tema claro",
81+
"dark-theme": "Tema oscuro",
82+
"offline": "Sin conexión",
83+
"status-ok": "Circulación normal",
84+
}
5885
};

source/js/functions/next-departures.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const nextDepartures = (station, from_gps = false) => {
5050
if (seconds_since_update <= 60) {
5151
$badge.addClass("-state--real-time").text(L10n[language]["real-time"]);
5252
} else {
53-
let last_updated = L10n[language]["updated"] + " " + moment(departures["lastUpdated"]).fromNow(true) + " " + L10n[language]["ago"];
53+
let last_updated = L10n[language]["updated"] + " " + moment(departures["lastUpdated"]).fromNow();
5454
$badge.text(last_updated);
5555
}
5656

0 commit comments

Comments
 (0)