diff --git a/Makefile b/Makefile index 56d2327..1e26fba 100644 --- a/Makefile +++ b/Makefile @@ -26,19 +26,26 @@ VERSION := 0.2 PROJECT := davadmin SRCFILES := $(wildcard admin/*.php) +JSFILES := admin/scripts/autocomplete.js admin/scripts/directories.js \ + admin/scripts/users.js APISRC := $(SRCFILES:,= ) TEMPDIR := $(shell mktemp -t -d davadmin.XXXXXXXXXX) XSRCFILES := $(patsubst %,$(TEMPDIR)/%,$(SRCFILES)) +XJSFILES := $(patsubst %,$(TEMPDIR)/%,$(JSFILES)) TRANSLANG := de POSRC := po -POFILES := $(foreach lang,$(TRANSLANG),$(POSRC)/$(lang).po) +POFILES := $(foreach lang,$(TRANSLANG),$(POSRC)/$(lang)/LC_MESSAGES/$(PROJECT).po) +JSPOFILES := $(foreach lang,$(TRANSLANG),$(POSRC)/$(lang)/LC_MESSAGES/$(PROJECT)js.po) MOFILES := $(patsubst %.po,%.mo,$(POFILES)) +JSMOFILES := $(patsubst %.po,%.mo,$(JSPOFILES)) POT=$(POSRC)/$(PROJECT).pot +JSPOT=$(POSRC)/$(PROJECT)js.pot +JSTRANS=$(POSRC)/transjs.txt .PHONY: all -all: $(POT) $(MOFILES) $(TEMPDIR)/delete +all: $(POT) $(JSPOT) $(JSTRANS) $(MOFILES) $(JSMOFILES) $(TEMPDIR)/delete -$(MOFILES): %.mo: %.po +$(MOFILES) $(JSMOFILES): %.mo: %.po @echo "msgfmt: $@" msgfmt -o$@ $< @@ -47,6 +54,11 @@ $(POFILES): %: $(POT) msgmerge -U $@ $(POT) touch $@ +$(JSPOFILES): %: $(JSPOT) + @echo "msgmerge: $@" + msgmerge -U $@ $(JSPOT) + touch $@ + $(POT): $(XSRCFILES) po/pot.sed @echo "xgettext: $@" cd $(TEMPDIR) && \ @@ -61,12 +73,42 @@ $(POT): $(XSRCFILES) po/pot.sed fi; \ done -.INTERMEDIATE: $(XSRCFILES) +$(JSPOT): $(XJSFILES) po/jspot.sed + @echo "xgettext: $@" + cd $(TEMPDIR) && \ + xgettext --default-domain=$(PROJECT)js --language=Java \ + --from-code=UTF-8 --keyword="intl.translate" \ + --msgid-bugs-address="jan@dittberner.info" -o- $(JSFILES) \ + | sed -f $(CURDIR)/po/jspot.sed \ + > $(CURDIR)/$@ + for pofile in $(JSPOFILES); do \ + if test ! -f $(CURDIR)/$${pofile}; then \ + cp $(CURDIR)/$@ $(CURDIR)/$${pofile}; \ + fi; \ + done + +$(JSTRANS): $(XJSFILES) + @echo "generate table of translatable string: $@" + cd $(TEMPDIR) && \ + xgettext --default-domain=$(PROJECT)js --language=Java \ + --from-code=UTF-8 \ + --omit-header --keyword="intl.translate" --properties-output \ + --no-location -o- $(JSFILES) \ + | awk '/^!.+=$$/ { print }' \ + | sed 's,.\(.*\)=,\1,g; s,\\=,=,g; s,\\ , ,g' \ + > $(CURDIR)/$@ + +.INTERMEDIATE: $(XSRCFILES) $(XJSFILES) $(XSRCFILES): $(TEMPDIR)/%: % @echo "processing: $<" mkdir -p $(@D) cp $< $@ +$(XJSFILES): $(TEMPDIR)/%: % + @echo "processing: $<" + mkdir -p $(@D) + cp $< $@ + $(TEMPDIR)/delete: rm -rf $(TEMPDIR) diff --git a/README b/README index a454cef..20866ff 100644 --- a/README +++ b/README @@ -27,14 +27,18 @@ Please see INSTALL_ for installation instructions. Used third party code ===================== -WebDAVAdmin uses the JQuery Javascript library for DOM manipulations -and AJAX calls. +DAVAdmin uses the JQuery Javascript library for DOM manipulations and +AJAX calls. .. _JQuery: http://www.jquery.com/ Version 1.2.1 of JQuery has been used for developing this software and is bundled in the ``scripts`` directory as ``jquery.js``. +DAVAdmin uses Marko Samastur's JavaScript i18n library. + +.. http://markos.gaivo.net/blog/?p=100. + License ======= diff --git a/admin/i18n.inc.php b/admin/i18n.inc.php index 34500bd..0504ed8 100644 --- a/admin/i18n.inc.php +++ b/admin/i18n.inc.php @@ -138,7 +138,11 @@ if ($_SESSION["language"]) { putenv(sprintf("LANG=%s", $_SESSION["language"])); putenv(sprintf("LANGUAGE=%s", $_SESSION["language"])); $_SESSION["locale"] = _setlocale(LC_ALL, $_SESSION["language"]); -bindtextdomain($project, realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . - ".." . DIRECTORY_SEPARATOR . "po")); +bindtextdomain($project, + realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . + ".." . DIRECTORY_SEPARATOR . "po")); +bindtextdomain($project . "js", + realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . + ".." . DIRECTORY_SEPARATOR . "po")); textdomain($project); ?> \ No newline at end of file diff --git a/admin/scripts/directories.js b/admin/scripts/directories.js index f2c653b..76d6800 100644 --- a/admin/scripts/directories.js +++ b/admin/scripts/directories.js @@ -27,7 +27,7 @@ */ function handleerror(xmldata) { if ($('error', xmldata).size()) { - var msg = 'Es ist ein Fehler aufgetreten:\n'; + var msg = intl.translate('An error occured:\n'); $('error', xmldata).find('errormsg').each(function(i) { msg += $(this).text(); }); @@ -44,9 +44,9 @@ function updateDirectories(xmldata) { var filecount = $('filecount', xmldata).text(); var filesize = $('filesize', xmldata).text(); var maydelete = $('maydelete', xmldata).text(); - var htmltext = '' + dirname + '' + groups + '' + filecount + ', ' + filesize + 'Gruppen'; + var htmltext = '' + dirname + '' + groups + '' + filecount + ', ' + filesize + '' + intl.translate('; if (maydelete == '1') { - htmltext = htmltext + 'löschen'; + htmltext = htmltext + '' + intl.translate('; } htmltext = htmltext + ''; $('#dirtable').find('tr#dir' + dirname).empty().append(htmltext); diff --git a/admin/scripts/i18n.php b/admin/scripts/i18n.php new file mode 100644 index 0000000..83cbb27 --- /dev/null +++ b/admin/scripts/i18n.php @@ -0,0 +1,52 @@ + + * @version $Id$ + * @license GPL + * @package DAVAdmin + * + * Copyright (c) 2007 Jan Dittberner + * + * This file is part of DAVAdmin. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA. + */ + +/** Include the internationalization code. */ +require_once(".." . DIRECTORY_SEPARATOR . "i18n.inc.php"); +textdomain("davadminjs"); + +$translatable = file(realpath(implode(DIRECTORY_SEPARATOR, + array(dirname(__FILE__), "..", "..", + "po", "transjs.txt")))); +header("Content-Type: application/x-javascript;charset=UTF-8"); +if (is_array($translatable)) { + print "i18nDict = "; + $transmap = array(); + foreach ($translatable as $sentence) { + $sentence = stripcslashes(stripcslashes(trim($sentence))); + $transmap[$sentence] = _($sentence); + } + print json_encode($transmap); + print ";"; +} else { + print "i18nDict = {};"; +} + +print("\n\nvar intl = new i18n(i18nDict);"); +?> \ No newline at end of file diff --git a/admin/scripts/translate.js b/admin/scripts/translate.js new file mode 100644 index 0000000..ab10bba --- /dev/null +++ b/admin/scripts/translate.js @@ -0,0 +1,80 @@ +/* + * Helper functions + */ +function stripStr(str) { + return str.replace(/^\s*/, "").replace(/\s*$/, ""); +} + +// Multiline strip +function stripStrML(str) { + // Split because m flag doesn't exist before JS1.5 and we need to + // strip newlines anyway + var parts = str.split('\n'); + for (var i=0; i 128) + newstr += "&#"+str.charCodeAt(i)+";"; + else + newstr += str.charAt(i); + } + return newstr; + } + + // Return translation, if translation dictionary exists and has a translation. + this.translate = function (str, params) { + var transl = str; + if (this.i18nd && this.i18nd[str]) + transl = this.i18nd[str]; + return printf(transl, params); + } + + this.translateNodes = function () { + var nodes = document.getElementsByTagName("*"); + for (var i=0;i + + \ No newline at end of file diff --git a/po/davadmin.pot b/po/davadmin.pot index 8e9d076..3f15f8e 100644 --- a/po/davadmin.pot +++ b/po/davadmin.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: davadmin 0.2\n" "Report-Msgid-Bugs-To: jan@dittberner.info\n" -"POT-Creation-Date: 2007-12-01 21:31+0100\n" +"POT-Creation-Date: 2007-12-01 23:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/po/davadminjs.pot b/po/davadminjs.pot new file mode 100644 index 0000000..5bd66ea --- /dev/null +++ b/po/davadminjs.pot @@ -0,0 +1,33 @@ +# DAVAdmin JavaScript. +# Copyright (C) 2007, Jan Dittberner +# This file is distributed under the same license as the davadmin package. +# Jan Dittberner , 2007. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: davadmin 0.2\n" +"Report-Msgid-Bugs-To: jan@dittberner.info\n" +"POT-Creation-Date: 2007-12-02 00:05+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: admin/scripts/directories.js:47 +msgid "Edit this directory's group assignments." +msgstr "" + +#: admin/scripts/directories.js:47 +msgid "groups" +msgstr "" + +#: admin/scripts/directories.js:49 +msgid "Delete this directory." +msgstr "" + +#: admin/scripts/directories.js:49 +msgid "delete" +msgstr "" diff --git a/po/de.mo b/po/de/LC_MESSAGES/davadmin.mo similarity index 98% rename from po/de.mo rename to po/de/LC_MESSAGES/davadmin.mo index 8df1a2a..a113832 100644 Binary files a/po/de.mo and b/po/de/LC_MESSAGES/davadmin.mo differ diff --git a/po/de/LC_MESSAGES/davadmin.po b/po/de/LC_MESSAGES/davadmin.po new file mode 100644 index 0000000..9fdb044 --- /dev/null +++ b/po/de/LC_MESSAGES/davadmin.po @@ -0,0 +1,114 @@ +# DAVAdmin. +# Copyright (C) 2007, Jan Dittberner +# This file is distributed under the same license as the davadmin package. +# Jan Dittberner , 2007. +# +msgid "" +msgstr "" +"Project-Id-Version: davadmin 0.2\n" +"Report-Msgid-Bugs-To: jan@dittberner.info\n" +"POT-Creation-Date: 2007-12-01 21:31+0100\n" +"PO-Revision-Date: 2007-12-02 00:01+0100\n" +"Last-Translator: Jan Dittberner \n" +"Language-Team: German \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: admin/common.inc.php:46 +msgid "Invalid call!" +msgstr "Ungültiger Aufruf!" + +#: admin/common.inc.php:74 admin/common.inc.php:82 admin/common.inc.php:90 +#: admin/common.inc.php:98 admin/common.inc.php:107 admin/common.inc.php:111 +#, php-format +msgid "%s is not defined." +msgstr "%s ist nicht definiert." + +#: admin/common.inc.php:78 +msgid "The specified digest file is not readable and writable." +msgstr "Die angegebene Digest-Datei ist nicht lesbar und schreibbar." + +#: admin/common.inc.php:86 +msgid "The specified group file is not readable and writable." +msgstr "Die angegebene Gruppendatei ist nicht lesbar und schreibbar." + +#: admin/common.inc.php:94 +msgid "The specified name mapping file is not readable and writable." +msgstr "Die angebene Mapping-Datei für Namen ist nicht lesbar und schreibbar." + +#: admin/common.inc.php:103 +msgid "The specified DAV directory is no directory or not accessable." +msgstr "Auf das angegeben DAV-Verzeichnis kann nicht zugegriffen werden." + +#: admin/directories.php:114 +#, php-format +msgid "%d kBytes" +msgstr "%d kByte" + +#: admin/directories.php:130 admin/directories.php:236 +#: admin/directories.php:275 +#, php-format +msgid "Invalid directory name %s!" +msgstr "Ungültiger Verzeichnisname: %s!" + +#: admin/directories.php:227 +#, php-format +msgid "There already is a directory entry named %s, but it's not a directory!" +msgstr "" +"Es gibt bereits einen Verzeichniseintrag mit dem Namen %s, aber dieser ist " +"kein Verzeichnis!" + +#: admin/directories.php:286 admin/directories.php:307 admin/users.php:344 +#: admin/users.php:365 admin/users.php:369 +#, php-format +msgid "Unexpected values %s!" +msgstr "Unerwarteter Wert: %s!" + +#: admin/directories.php:303 +msgid "Delete failed!" +msgstr "Das Löschen ist fehlgeschlagen!" + +#: admin/shared.inc.php:42 +msgid "" +"The Server is not configured correctly. Please tell your Administrator to " +"set the DavAdminConfDir environment variable." +msgstr "" +"Der Server ist nicht richtig konfiguriert. Bitten Sie Ihren Administrator " +"darum, die Umgebungsvariable DavAdminConfDir zu setzen." + +#: admin/shared.inc.php:49 +#, php-format +msgid "" +"The server configuration file '%s' doesn't exist. Please create the file " +"with correct settings." +msgstr "Die Serverkonfigurationsdatei '%s' existiert nicht. Bitte legen Sie diese Datei mit den korrekten Einstellungen an." + +#: admin/users.php:64 admin/users.php:84 admin/users.php:327 +#, php-format +msgid "Invalid user id %s" +msgstr "Ungültige Benutzer-Id %s" + +#: admin/users.php:105 +msgid "Uid must be numeric." +msgstr "Nutzer-Id muss ein numerischer Wert sein." + +#: admin/users.php:108 admin/users.php:115 +msgid "Password must be at least 8 characters long." +msgstr "Das Passwort muss mindestens 8 Zeichen lang sein." + +#: admin/users.php:112 +msgid "" +"Username must be at least 2 characters long and must contain letters and " +"digits only." +msgstr "" +"Der Nutzername muss mindestens zwei Zeichen lang sein und darf nur aus " +"Buchstaben und Zahlen bestehen." + +#: admin/users.php:125 +msgid "" +"Groups must be a list of group names separated by commas. Group names must " +"consist of letters and digits." +msgstr "" +"Im Feld Gruppen muss eine durch Kommata getrennte Liste von Gruppennamen " +"stehen. Gruppennamen dürfen aus Buchstaben und Zahlen bestehen." diff --git a/po/de/LC_MESSAGES/davadminjs.mo b/po/de/LC_MESSAGES/davadminjs.mo new file mode 100644 index 0000000..3a42cd4 Binary files /dev/null and b/po/de/LC_MESSAGES/davadminjs.mo differ diff --git a/po/de/LC_MESSAGES/davadminjs.po b/po/de/LC_MESSAGES/davadminjs.po new file mode 100644 index 0000000..d2295a1 --- /dev/null +++ b/po/de/LC_MESSAGES/davadminjs.po @@ -0,0 +1,32 @@ +# DAVAdmin. +# Copyright (C) 2007, Jan Dittberner +# This file is distributed under the same license as the davadmin package. +# Jan Dittberner , 2007. +# +msgid "" +msgstr "" +"Project-Id-Version: davadmin 0.2\n" +"Report-Msgid-Bugs-To: jan@dittberner.info\n" +"POT-Creation-Date: 2007-12-02 00:01+0100\n" +"PO-Revision-Date: 2007-12-02 00:01+0100\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: admin/scripts/directories.js:47 +msgid "Edit this directory's group assignments." +msgstr "Die Gruppenzuordnungen dieses Verzeichnisses bearbeiten." + +#: admin/scripts/directories.js:47 +msgid "groups" +msgstr "Gruppen" + +#: admin/scripts/directories.js:49 +msgid "Delete this directory." +msgstr "Dieses Verzeichnis löschen." + +#: admin/scripts/directories.js:49 +msgid "delete" +msgstr "löschen" diff --git a/po/jspot.sed b/po/jspot.sed new file mode 100644 index 0000000..9f1af6c --- /dev/null +++ b/po/jspot.sed @@ -0,0 +1,30 @@ +# Copyright (c) 2007 Jan Dittberner. $Revision$ +# +# inspired by Alex Tingle's pot.sed from +# http://blogs.admissions.buffalo.edu/news/wp-content/plugins/eventcalendar3/gettext/pot.sed +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + +# Fills in some details in the ec3.pot file. +1,/^$/ { + s/SOME DESCRIPTIVE TITLE/DAVAdmin JavaScript/ + s/YEAR THE PACKAGE.S COPYRIGHT HOLDER/2007, Jan Dittberner/ + s/PACKAGE/davadmin/ + s/FIRST AUTHOR , YEAR./Jan Dittberner , 2007./ + s/VERSION/0.2/ + s/CHARSET/UTF-8/ +} + diff --git a/po/transjs.txt b/po/transjs.txt new file mode 100644 index 0000000..20e6dd2 --- /dev/null +++ b/po/transjs.txt @@ -0,0 +1,4 @@ +Edit this directory's group assignments. +groups +Delete this directory. +delete