lucidAuth/public/misc/script.translation.js
Danny Bessems 3dbb6b9932 Implemented GUI aspect of usermanagement page
TODO: add ajax-call that will update database
2019-03-06 14:21:47 +01:00

60 lines
2.1 KiB
JavaScript

var locales = {
en: {
button_new: "new",
button_save: "save",
button_cancel: "cancel",
button_sessions: "sessions",
button_delete: "delete",
button_login: "login",
heading_error: "ERROR!",
label_password: "Password:",
label_username: "Username:",
link_logout: "Logout",
span_credentialsavailable: "Login credentials available upon request!",
span_loggedinas: "Logged in as",
th_username: "Username",
th_role: "Role",
th_manage: "Manage"
},
nl: {
button_new: "nieuw",
button_save: "opslaan",
button_cancel: "annuleren",
button_sessions: "sessies",
button_delete: "verwijder",
button_login: "log in",
heading_error: "FOUT!",
label_password: "Wachtwoord:",
label_username: "Gebruikersnaam:",
link_logout: "Log uit",
span_credentialsavailable: "Inloggegevens verkrijgbaar op aanvraag!",
span_loggedinas: "Ingelogd als",
th_username: "Gebruikersnaam",
th_role: "Rol",
th_manage: "Beheer"
} // ... etc.
};
$(document).ready(function(){
$('[id^=linklanguage-]').click(function() {
var selectedlang = $(this).attr('id').split('-')[1];
// Replace text of each element with translated value
$('[data-translation]').each(function() {
$(this).text(locales[selectedlang][$(this).data('translation')]);
});
// Enable/disable (toggle) anchors
$('span#user a.current').removeClass('current');
$(this).addClass('current');
// Store current languagesetting in persistent localstorage
localStorage.setItem('language', selectedlang);
});
if (localStorage.getItem('language') !== null) {
$('[data-translation]').each(function() {
$(this).text(locales[localStorage.getItem('language')][$(this).data('translation')]);
});
$('span#user a.current').removeClass('current');
$('#linklanguage-' + localStorage.getItem('language')).addClass('current');
}
});