From 5a707eda4d0c901ea9acab437f195fc5fc65b328 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sun, 2 Dec 2007 19:50:29 +0000 Subject: [PATCH] fixes #10 * all JavaScript strings are marked with intl.translate() --- admin/scripts/autocomplete.js | 3 ++- admin/scripts/directories.js | 24 ++++++---------------- admin/scripts/helper.js | 13 ++++++++++++ admin/scripts/users.js | 38 ++++++++++++----------------------- 4 files changed, 34 insertions(+), 44 deletions(-) diff --git a/admin/scripts/autocomplete.js b/admin/scripts/autocomplete.js index 2e28d07..9154ad7 100644 --- a/admin/scripts/autocomplete.js +++ b/admin/scripts/autocomplete.js @@ -309,7 +309,8 @@ DAV.ACDB.prototype.search = function (searchString) { } }, error: function (xmlhttp) { - alert('An HTTP error '+ xmlhttp.status +' occured.\n'+ db.uri); + alert(intl.translate("A HTTP error %s occured.\n%s", + [xmlhttp.status, db.uri])); } }); }, this.delay); diff --git a/admin/scripts/directories.js b/admin/scripts/directories.js index 76d6800..09b2a62 100644 --- a/admin/scripts/directories.js +++ b/admin/scripts/directories.js @@ -25,18 +25,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. */ -function handleerror(xmldata) { - if ($('error', xmldata).size()) { - var msg = intl.translate('An error occured:\n'); - $('error', xmldata).find('errormsg').each(function(i) { - msg += $(this).text(); - }); - alert(msg); - return true; - } - return false; - $('#content').show(); -} function updateDirectories(xmldata) { var dirname = $('dirname', xmldata).text(); @@ -74,7 +62,7 @@ function updateDirectories(xmldata) { } function getDirectoryForm(title, dirname, groups) { - return '
Schließen ' + title + '
'; + return '
' + intl.translate( ' + title + '
'; } function displaydirectoryeditor(title, dirname, groups) { @@ -89,7 +77,7 @@ function displaydirectoryeditor(title, dirname, groups) { }); $('#dirform').submit(function() { if (!this.dirname.value.match(/^[a-zA-Z0-9 -_.]+$/)) { - alert("Ungültiger Verzeichnisname."); + alert(intl.translate("Invalid directory name.")); this.dirname.focus(); return false; } @@ -119,20 +107,20 @@ function editdirectory(dirname) { var dirname, groups; dirname = $("dirname:first", retval).text(); groups = $("groups:first", retval).text(); - displaydirectoryeditor("Verzeichnisdaten bearbeiten", + displaydirectoryeditor(intl.translate("Edit directory data"), dirname, groups); } }); } function newdirectory() { - displaydirectoryeditor('Neues Verzeichnis anlegen', '', ''); + displaydirectoryeditor(intl.translate("Create new directory"), '', ''); } function deletedirectorydialog(dirname) { $("#direditor").hide().empty(); - var msg = 'Soll das Verzeichnis ' + dirname + - ' wirklich gelöscht werden?'; + var msg = intl.translate("Should the directory %s really get deleted?", + [dirname]); if (confirm(msg) == true) { $.post( "directories.php", diff --git a/admin/scripts/helper.js b/admin/scripts/helper.js index ef88ab2..81b922d 100644 --- a/admin/scripts/helper.js +++ b/admin/scripts/helper.js @@ -49,3 +49,16 @@ DAV.encodeURIComponent = function (item, uri) { item = encodeURIComponent(item).replace('%2F', '/'); return uri.indexOf('?q=') ? item : item.replace('%26', '%2526').replace('%23', '%2523'); }; + +function handleerror(xmldata) { + if ($('error', xmldata).size()) { + var msg = intl.translate("An error occured:\n"); + $('error', xmldata).find('errormsg').each(function(i) { + msg += $(this).text(); + }); + alert(msg); + return true; + } + return false; + $('#content').show(); +} diff --git a/admin/scripts/users.js b/admin/scripts/users.js index fe8daa6..18e5d5c 100644 --- a/admin/scripts/users.js +++ b/admin/scripts/users.js @@ -25,18 +25,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. */ -function handleerror(xmldata) { - if ($('error', xmldata).size()) { - var msg = 'Es ist ein Fehler aufgetreten:\n'; - $('error', xmldata).find('errormsg').each(function(i) { - msg += $(this).text(); - }); - alert(msg); - $('#content').show(); - return true; - } - return false; -} function updateusers(xmldata) { var uid = $(xmldata).find('uid').text(); @@ -44,9 +32,9 @@ function updateusers(xmldata) { var firstname = $(xmldata).find('firstname').text(); var lastname = $(xmldata).find('lastname').text(); var loggedin = $(xmldata).find('loggedin').text(); - var htmltext = '' + username + '' + lastname + ', ' + firstname + 'bearbeiten'; + var htmltext = '' + username + '' + lastname + ', ' + firstname + '' + intl.translate('; if (loggedin == '0') { - htmltext = htmltext + 'löschen'; + htmltext = htmltext + '' + intl.translate('; } htmltext = htmltext + ''; $('#usertable').find('tr#uid' + uid).empty().append(htmltext); @@ -76,11 +64,11 @@ function updateusers(xmldata) { function getEditUserForm(title, username, firstname, lastname, groups, userid) { var retval; - retval = '
Schließen ' + title + '
' + title + '
'; + retval = retval + '/>
'; return retval; } @@ -97,25 +85,25 @@ function displayusereditor(title, userid, username, firstname, lastname, groups) var params; if (userid == null) { if (!this.username.value.match(/^[a-zA-Z0-9]{2,}$/)) { - alert('Der Nutzername muss aus mindestens 2 Buchstaben oder Ziffern bestehen und darf keine sonstigen Zeichen enthalten.'); + alert(intl.translate("The user name must consist of at least 2 letters or digits and no other characters!")); this.username.focus(); return false; } } if (userid == null || this.pwd1.value.length > 0) { if (this.pwd1.value.length < 8) { - alert('Das Passwort muss mindestens 8 Zeichen lang sein!'); + alert(intl.translate("The password must have a lenght of at least 8 characters!")); this.pwd1.focus(); return false; } if (this.pwd1.value != this.pwd2.value) { - alert('Passwort und Wiederholung müssen übereinstimmen!'); + alert(intl.translate("Password and confirmation have to match!")); this.pwd2.focus(); return false; } } if (!this.groups.value.match(/^([0-9a-zA-z]+[,\s]*)+$/)) { - alert('Die Gruppenangabe muss eine durch Kommata getrennte Liste von Gruppennamen, die aus Buchstaben und Ziffern zusammengesetzt sein können, sein.'); + alert(intl.translate("The groups field has to be a comma separated list of group names which must consist of letters or digits!")); this.groups.focus(); return false; } @@ -149,8 +137,7 @@ function displayusereditor(title, userid, username, firstname, lastname, groups) function deleteuserdialog(userid, username, firstname, lastname) { $("#usereditor").hide().empty(); - var msg = 'Soll der Nutzer ' + firstname + ' ' + lastname + - ' mit dem Login ' + username + ' wirklich gelöscht werden?'; + var msg = intl.translate("Should the user %s %s with the user name %s really get deleted?", [firstname, lastname, username]); if (confirm(msg) == true) { $.post( "users.php", @@ -193,14 +180,15 @@ function edituser(userid) { lastname = $("lastname:first", retval).text(); firstname = $("firstname:first", retval).text(); groups = $("groups:first", retval).text(); - displayusereditor('Nutzerdaten bearbeiten', userid, username, - firstname, lastname, groups); + displayusereditor(intl.translate("Edit user data"), + userid, username, firstname, lastname, + groups); } }); } function newuser() { - displayusereditor('Neuen Nutzer anlegen', null, '', '', '', ''); + displayusereditor(intl.translate("Create new user"), null, '', '', '', ''); } $(function() {