60 lines
2.0 KiB
JavaScript
60 lines
2.0 KiB
JavaScript
|
var locales = {
|
||
|
en: {
|
||
|
button_add: "add",
|
||
|
button_cancel: "cancel",
|
||
|
button_continue: "continue",
|
||
|
button_delete: "delete",
|
||
|
button_login: "login",
|
||
|
heading_error: "ERROR!",
|
||
|
label_password: "Password:",
|
||
|
label_username: "Username:",
|
||
|
label_selectbrowser: "Select browser:",
|
||
|
link_install: "Install!",
|
||
|
link_logout: "Logout",
|
||
|
link_plugin: "Browser plugin",
|
||
|
span_credentialsavailable: "Login credentials available upon request!",
|
||
|
span_loggedinas: "Logged in as",
|
||
|
span_plugin: "Browser plugin?"
|
||
|
},
|
||
|
nl: {
|
||
|
button_add: "voeg toe",
|
||
|
button_cancel: "annuleer",
|
||
|
button_continue: "doorgaan",
|
||
|
button_delete: "verwijder",
|
||
|
button_login: "log in",
|
||
|
heading_error: "FOUT!",
|
||
|
label_password: "Wachtwoord:",
|
||
|
label_username: "Gebruikersnaam:",
|
||
|
label_selectbrowser: "Selecteer browser:",
|
||
|
link_install: "Installeer!",
|
||
|
link_logout: "Log uit",
|
||
|
link_plugin: "Browser plugin",
|
||
|
span_credentialsavailable: "Inloggegevens verkrijgbaar op aanvraag!",
|
||
|
span_loggedinas: "Ingelogd als",
|
||
|
span_plugin: "Browser plugin?"
|
||
|
} // ... 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(index) {
|
||
|
$(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(index) {
|
||
|
$(this).text(locales[localStorage.getItem('language')][$(this).data('translation')]);
|
||
|
});
|
||
|
$('span#user a.current').removeClass('current');
|
||
|
$('#linklanguage-' + localStorage.getItem('language')).addClass('current');
|
||
|
}
|
||
|
});
|