Skip to content
This repository has been archived by the owner on Apr 15, 2022. It is now read-only.

Commit

Permalink
Implement page translations
Browse files Browse the repository at this point in the history
Close #4
Rename app.js to accessibility.js
  • Loading branch information
mikojimnz committed Nov 3, 2021
1 parent 73be453 commit e0a9203
Show file tree
Hide file tree
Showing 8 changed files with 1,020 additions and 20 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion app/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,5 @@ <h5>October 29</h5>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.7/js/tether.min.js" integrity="sha384-CPFFlrdhp9pDDCqRqdTKNZ5oAHsnfnvHGt0CsRIeL5Gc7V/OkP1Y4w8zTxlV3mat" crossorigin="anonymous"></script>
<script src="https://cdn.ucf.edu/athena-framework/v1.1.0/js/framework.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js"></script>
<script src="../scripts/app.js"></script>
<script src="../scripts/accessibility.js"></script>
</html>
14 changes: 8 additions & 6 deletions app/preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h4 class="pt-4">Emergency Notifications</h4>
<p>Emergency alerts and notifications.</p>
<button type="button" class="btn btn-success btn-toggle">Enabled</button>
<h4 class="pt-4">News & Events</h4>
<p>Calender alerts, new events.</p>
<p>Calendar alerts, new events.</p>
<button type="button" class="btn btn-success btn-toggle">Enabled</button>
<h4 class="pt-4">Transit Notifications</h4>
<p>Parking, travel time.</p>
Expand All @@ -111,10 +111,10 @@ <h2 class="heading-underline">Language Preferences</h2>
Change Language
</button>
<div class="dropdown-menu" aria-labelledby="dropdownLanguage">
<a class="dropdown-item" href="#">English</a>
<a class="dropdown-item" href="#">Spanish</a>
<a class="dropdown-item" href="#">French</a>
<a class="dropdown-item" href="#">German</a>
<a class="dropdown-item" href="#" id="lang_en">English</a>
<a class="dropdown-item" href="#" id="lang_es">Español</a>
<a class="dropdown-item" href="#" id="lang_fr">François</a>
<a class="dropdown-item" href="#" id="lang_de">Deutsch</a>
</div>
</div>
</div>
Expand Down Expand Up @@ -166,5 +166,7 @@ <h4 class="pt-4">Dark Mode</h4>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.7/js/tether.min.js" integrity="sha384-CPFFlrdhp9pDDCqRqdTKNZ5oAHsnfnvHGt0CsRIeL5Gc7V/OkP1Y4w8zTxlV3mat" crossorigin="anonymous"></script>
<script src="https://cdn.ucf.edu/athena-framework/v1.1.0/js/framework.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js"></script>
<script src="../scripts/app.js"></script>
<script src="../locales/preferences.js"></script>
<script src="../scripts/lingumania.js"></script>
<script src="../scripts/accessibility.js"></script>
</html>
154 changes: 154 additions & 0 deletions locales/preferences.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
var linguJSON = {
"custom_lang_switcher_container_id": "#lingumania",
"languages": [
{
"lang_name": "English",
"lang_code": "en",
"url_pattern": "?"
},
{
"lang_name": "Español",
"lang_code": "es",
"url_pattern": "?"
},
{
"lang_name": "François",
"lang_code": "fr",
"url_pattern": "?"
},
{
"lang_name": "Deutsch",
"lang_code": "de",
"url_pattern": "?"
}
],
"translated_segments": [
{
"source": "Preferences",
"target_es": "Preferencias",
"target_fr": "Préférences",
"target_de": "Einstellungen"
},
{
"source": "Change Campus",
"target_es": "Cambiar campus",
"target_fr": "Changer de campus",
"target_de": "Campus wechseln"
},
{
"source": "Select Campus",
"target_es": "Seleccionar campus",
"target_fr": "Sélectionnez le campus",
"target_de": "Campus auswählen"
},
{
"source": "Location Preferences",
"target_es": "Preferencias de ubicación",
"target_fr": "Préférences d'emplacement",
"target_de": "Standorteinstellungen"
},
{
"source": "Allow location services.",
"target_es": "Permitir servicios de ubicación.",
"target_fr": "Autoriser les services de localisation.",
"target_de": "Ortungsdienste zulassen."
},
{
"source": "Notification Preferences",
"target_es": "Preferencias de notificación",
"target_fr": "Préférences de notification",
"target_de": "Benachrichtigungseinstellungen"
},
{
"source": "Emergency Notifications",
"target_es": "Notificaciones de emergencia",
"target_fr": "Notifications d'urgence",
"target_de": "Notfallbenachrichtigungen"
},
{
"source": "Emergency alerts and notifications.",
"target_es": "Alertas y notificaciones de emergencia.",
"target_fr": "Alertes et notifications d'urgence.",
"target_de": "Notfallwarnungen und Benachrichtigungen."
},
{
"source": "News & Events",
"target_es": "Noticias y Eventos",
"target_fr": "Nouvelles et événements",
"target_de": "Neuigkeiten und Veranstaltungen"
},
{
"source": "Calendar alerts, new events.",
"target_es": "Alertas de calendario, nuevos eventos.",
"target_fr": "Alertes de calendrier, nouveaux événements.",
"target_de": "Kalenderbenachrichtigungen, neue Ereignisse."
},
{
"source": "Parking, travel time.",
"target_es": "Aparcamiento, tiempo de viaje.",
"target_fr": "Stationnement, temps de trajet.",
"target_de": "Parking, travel time."
},
{
"source": "Language Preferences",
"target_es": "Preferencias de idioma",
"target_fr": "Préférences de langue",
"target_de": "Sprache ändern"
},{
"source": "Change Language",
"target_es": "Cambiar idioma",
"target_fr": "Changer de langue",
"target_de": ""
},
{
"source": "Accessibility",
"target_es": "Accesibilidad",
"target_fr": "Accessibilité",
"target_de": "Barrierefreiheit"
},
{
"source": "Smaller",
"target_es": "Mas pequeño",
"target_fr": "Plus petite",
"target_de": "Smaller"
},
{
"source": "Normal",
"target_es": "Normal",
"target_fr": "Normal",
"target_de": "Normal"
},
{
"source": "Larger",
"target_es": "Más grande",
"target_fr": "Plus grand",
"target_de": "Farben mit hohem Kontrast"
},
{
"source": "High Contrast Colors",
"target_es": "Colores de alto contraste",
"target_fr": "Couleurs à contraste élevé",
"target_de": ""
},
{
"source": "Dark Mode",
"target_es": "Modo oscuro",
"target_fr": "Mode sombre",
"target_de": "Dunkler Modus"
},
{
"source": "Enabled",
"target_es": "Activado",
"target_fr": "Activé",
"target_de": "Ermöglicht"
},
{
"source": "Disabled",
"target_es": "Discapacitado",
"target_fr": "Désactivé",
"target_de": "Behinderte"
}

]
};

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dig4104c",
"version": "0.2.0",
"version": "0.3.0",
"description": "UCF Mobile App Prototype",
"main": "index.html",
"scripts": {
Expand Down
59 changes: 49 additions & 10 deletions scripts/app.js → scripts/accessibility.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
let ui_locales = {
"Enabled":
{
"en": "Enabled",
"es": "Activado",
"fr": "Activé",
"de": "Ermöglicht"
},
"Disabled": {
"en": "Disabled",
"es": "Discapacitado",
"fr": "Désactivé",
"de": "Behinderte"
}
}

/* Get font size based on preferences */
function setFontSize() {
let accessibleText = "a, button:not('.text-size-toggle'), h1, h2, h3, h4, h5, h6, p";
Expand Down Expand Up @@ -49,13 +65,13 @@ function setDarkMode() {
if(Cookies.get('darkMode') == "true") {
$("#dark-mode-toggle").addClass("btn-success");
$("#dark-mode-toggle").removeClass("btn-default");
$("#dark-mode-toggle").text("Enabled");
$("#dark-mode-toggle").text(ui_locales['Enabled'][Cookies.get('lang')]);

$(accessibleElements).addClass("darkmode");
} else {
$("#dark-mode-toggle").addClass("btn-default");
$("#dark-mode-toggle").removeClass("btn-success");
$("#dark-mode-toggle").text("Disabled");
$("#dark-mode-toggle").text(ui_locales['Disabled'][Cookies.get('lang')]);

$(accessibleElements).removeClass("darkmode");
}
Expand All @@ -64,13 +80,11 @@ function setDarkMode() {
/* Toggle clickable buttons */
$(".btn-toggle").on("click", function(){
if ($(this).hasClass("btn-success")) {
$(this).addClass("btn-default");
$(this).removeClass("btn-success");
$(this).text("Disabled");
$(this).toggleClass("btn-default btn-success");
$(this).text(ui_locales['Disabled'][Cookies.get('lang')]);
} else {
$(this).addClass("btn-success");
$(this).removeClass("btn-default");
$(this).text("Enabled");
$(this).toggleClass("btn-default btn-success");
$(this).text(ui_locales['Enabled'][Cookies.get('lang')]);
}
});

Expand Down Expand Up @@ -99,5 +113,30 @@ $("#dark-mode-toggle").on("click", function() {
}
});

setFontSize()
setDarkMode();
/* Set language preferences */
$("#lang_en").on("click", function() {
Cookies.set('lang', 'en');
location.reload();
});
$("#lang_es").on("click", function() {
Cookies.set('lang', 'es');
location.reload();
});
$("#lang_fr").on("click", function() {
Cookies.set('lang', 'fr');
location.reload();
});
$("#lang_de").on("click", function() {
Cookies.set('lang', 'de');
location.reload();
});

/* Initalize accessibility features */
setFontSize();
setDarkMode();

/* Default cookies */
$(window).on("load", function() {
if (Cookies.get('lang') == undefined)
Cookies.set('lang', 'en');
});
Loading

0 comments on commit e0a9203

Please sign in to comment.