From 882b9d1bb7d2cf73d79ef5a87c3cbaffc9dc8c99 Mon Sep 17 00:00:00 2001 From: lars Date: Tue, 20 Sep 2005 22:29:55 +0000 Subject: [PATCH] removed last hard coded texts 'EnterCurrentCryptoPassword' added to language files 'EnterAdminPassword' renamed to 'EnterCurrentAdminPassword' language file loaded immeadiately before rendering sort language links in web interface lexically reordered 'find' options to avoid warnings --- cbox-tree.d/usr/share/cryptobox/lang/de.hdf | 7 +- cbox-tree.d/usr/share/cryptobox/lang/en.hdf | 9 +- cbox-tree.d/usr/share/cryptobox/lang/si.hdf | 3 +- .../share/cryptobox/templates/config_form.cs | 2 +- .../share/cryptobox/templates/init_form.cs | 2 +- .../usr/share/cryptobox/templates/macros.cs | 1 + .../share/cryptobox/templates/mount_form.cs | 6 +- cbox-tree.d/var/www/cgi-bin/cryptobox.pl | 89 ++++++++++--------- scripts/validate.sh | 6 +- 9 files changed, 65 insertions(+), 60 deletions(-) diff --git a/cbox-tree.d/usr/share/cryptobox/lang/de.hdf b/cbox-tree.d/usr/share/cryptobox/lang/de.hdf index 166b4d2..dd5dba1 100644 --- a/cbox-tree.d/usr/share/cryptobox/lang/de.hdf +++ b/cbox-tree.d/usr/share/cryptobox/lang/de.hdf @@ -15,9 +15,10 @@ Lang { Text { + EnterCurrentCryptoPassword = Das Crypto-Passwort eingeben: EnterNewCryptoPassword = Das neue Crypto-Passwort eingeben: EnterSameCryptoPassword = Das Crypto-Passwort wiederholen: - EnterAdminPassword = Das bisherige Admin-Passwort eingeben: + EnterCurrentAdminPassword = Das aktuelle Admin-Passwort eingeben: EnterNewAdminPassword = Das neue Admin-Passwort eingeben: EnterSameAdminPassword = Das neue Admin-Passwort wiederholen: InitWarning = Bei der Initialisierung werden ALLE DATEN auf der Festplatte GELÖSCHT! @@ -41,8 +42,8 @@ Lang { DoInit = CryptoBox initialisieren SaveConfig = Speichere Konfiguration Update = Aktualisieren - Mount = CryptoDaten aktivieren - Umount = CryptoDaten deaktivieren + Mount = Crypto-Daten aktivieren + Umount = Crypto-Daten deaktivieren Config = Einstellungen PowerOff = ausschalten ReBoot = neu starten diff --git a/cbox-tree.d/usr/share/cryptobox/lang/en.hdf b/cbox-tree.d/usr/share/cryptobox/lang/en.hdf index 219a238..9b5ed03 100644 --- a/cbox-tree.d/usr/share/cryptobox/lang/en.hdf +++ b/cbox-tree.d/usr/share/cryptobox/lang/en.hdf @@ -15,9 +15,10 @@ Lang { Text { + EnterCurrentCryptoPassword = Enter the crypto password: EnterNewCryptoPassword = Enter the new crypto password: EnterSameCryptoPassword = Repeat the new crypto password: - EnterAdminPassword = Enter the current administration password: + EnterCurrentAdminPassword = Enter the current administration password: EnterNewAdminPassword = Enter the new administration password: EnterSameAdminPassword = Repeat the new administration password: InitWarning = During the process of initialization ALL DATA on the hard drive WILL BE DELETED! @@ -30,7 +31,7 @@ Lang { SelectLanguage = Language preferences: RedirectNote = Click here if your browser does not support automatic redirection. ProjectHomePage = Website of project - ProjectNote = The CryptoBox is a product of + ProjectNote = The CryptoBox is a project of DoUmount = Deactivation of the encrypted filesystem DoMount = Activation of the encrypted filesystem Configuration = Configuration @@ -41,8 +42,8 @@ Lang { DoInit = Initialize CryptoBox SaveConfig = Save configuration Update = Refresh - Mount = activate encrypted filesystem - Umount = deactivate encrypted filesystem + Mount = Activate encrypted filesystem + Umount = Deactivate encrypted filesystem Config = Configuration PowerOff = Shutdown ReBoot = Reboot diff --git a/cbox-tree.d/usr/share/cryptobox/lang/si.hdf b/cbox-tree.d/usr/share/cryptobox/lang/si.hdf index c0a0583..822ba36 100644 --- a/cbox-tree.d/usr/share/cryptobox/lang/si.hdf +++ b/cbox-tree.d/usr/share/cryptobox/lang/si.hdf @@ -15,9 +15,10 @@ Lang { Text { + EnterCurrentCryptoPassword = Vpišite geslo: EnterNewCryptoPassword = Vpišite novo geslo: EnterSameCryptoPassword = Ponovite novo geslo: - EnterAdminPassword = Vnesite trenutno obstoječe geslo administratorja/ke: + EnterCurrentAdminPassword = Vnesite trenutno obstoječe geslo administratorja/ke: EnterNewAdminPassword = Vnesite novo geslo administratorja/ke: EnterSameAdminPassword = Ponovite novo geslo administratorja/ke: InitWarning = Med incializacijo bodo VSI PODATKI z vašega trdega diska IZBRISANI! diff --git a/cbox-tree.d/usr/share/cryptobox/templates/config_form.cs b/cbox-tree.d/usr/share/cryptobox/templates/config_form.cs index 6ba3682..ec9cbdf 100644 --- a/cbox-tree.d/usr/share/cryptobox/templates/config_form.cs +++ b/cbox-tree.d/usr/share/cryptobox/templates/config_form.cs @@ -5,7 +5,7 @@ enctype="application/x-www-form-urlencoded"> -


+


diff --git a/cbox-tree.d/usr/share/cryptobox/templates/init_form.cs b/cbox-tree.d/usr/share/cryptobox/templates/init_form.cs index e363b7f..e5d38cd 100644 --- a/cbox-tree.d/usr/share/cryptobox/templates/init_form.cs +++ b/cbox-tree.d/usr/share/cryptobox/templates/init_form.cs @@ -5,7 +5,7 @@

-


+



diff --git a/cbox-tree.d/usr/share/cryptobox/templates/macros.cs b/cbox-tree.d/usr/share/cryptobox/templates/macros.cs index c46a5b9..5ad4e48 100644 --- a/cbox-tree.d/usr/share/cryptobox/templates/macros.cs +++ b/cbox-tree.d/usr/share/cryptobox/templates/macros.cs @@ -70,6 +70,7 @@ Aktivierung des verschlüsselten Dateisystems +

-

+

- +
diff --git a/cbox-tree.d/var/www/cgi-bin/cryptobox.pl b/cbox-tree.d/var/www/cgi-bin/cryptobox.pl index 6315103..489f9db 100755 --- a/cbox-tree.d/var/www/cgi-bin/cryptobox.pl +++ b/cbox-tree.d/var/www/cgi-bin/cryptobox.pl @@ -13,7 +13,7 @@ use ConfigFile; my ($pagedata, $pagename); -my ($LANGUAGE_DIR, $LANGUAGE, $HTML_TEMPLATE_DIR, $DOC_DIR); +my ($LANGUAGE_DIR, $DEFAULT_LANGUAGE, $HTML_TEMPLATE_DIR, $DOC_DIR); my ($CB_SCRIPT, $LOG_FILE, $IS_DEV); my $config = ConfigFile::read_config_file('/etc/cryptobox/cryptobox.conf'); @@ -21,12 +21,13 @@ my $config = ConfigFile::read_config_file('/etc/cryptobox/cryptobox.conf'); $CB_SCRIPT = $config->{CB_SCRIPT}; $LOG_FILE = $config->{LOG_FILE}; $LANGUAGE_DIR = $config->{LANGUAGE_DIR}; -# language setting may be later overriden by "weblang" -$LANGUAGE = $config->{LANGUAGE}; +$DEFAULT_LANGUAGE = $config->{LANGUAGE}; $HTML_TEMPLATE_DIR = $config->{HTML_TEMPLATE_DIR}; $DOC_DIR = $config->{DOC_DIR}; $IS_DEV = ( -e $config->{DEV_FEATURES_SCRIPT}); +my $query = new CGI; + #################### subs ###################### @@ -47,24 +48,52 @@ sub load_hdf (my $script_url = $ENV{'SCRIPT_NAME'}) =~ m/^[^&]*/; $hdf->setValue("ScriptName", ($ENV{'SCRIPT_NAME'} eq '/')? '/cryptobox' : $script_url ); - &load_language_data($hdf, $LANGUAGE); - &get_available_languages($hdf); return $hdf; } -sub load_language_data -# import the specified language data -# every call overrides previously loaded values -# it is sufficient to call it somewhere before "render" +sub load_selected_language { my $data = shift; - my $lang = shift; - my $fname = "$LANGUAGE_DIR/$lang" . '.hdf'; - die ("Language file ($fname) not found!") unless (-e "$fname"); - $data->readFile("$fname"); + my $config_language; + + # load $DEFAULT_LANGUAGE - this is necessary, if a translation is incomplete + $data->readFile("$LANGUAGE_DIR/$DEFAULT_LANGUAGE" . ".hdf"); + + # load configured language, if it is valid + $config_language = `$CB_SCRIPT get_config language`; + $config_language = $DEFAULT_LANGUAGE unless (&validate_language("$config_language")); + + ######### temporary language setting? ############ + # the default language can be overriden by the language links in the + # upper right of the page + if ($query->param('weblang')) { + my $weblang = $query->param('weblang'); + if (&validate_language($weblang)) { + # load the data + $config_language = "$weblang"; + # add the setting to every link + $pagedata->setValue('Data.PostData.weblang', "$weblang"); + } else { + $pagedata->setValue('Data.Warning', 'InvalidLanguage'); + } + } + # import the configured resp. the temporarily selected language + $data->readFile("$LANGUAGE_DIR/$config_language" . ".hdf"); + + ########## select documentation language ########## + if (&validate_doc_language($config_language)) { + # selected web interface language + $pagedata->setValue('Settings.DocLang', "$config_language"); + } elsif (&validate_doc_language($DEFAULT_LANGUAGE)) { + # configured CryptoBox language + $pagedata->setValue('Settings.DocLang', "$DEFAULT_LANGUAGE"); + } else { + # default hardcoded language (english) + $pagedata->setValue('Settings.DocLang', "en"); + } } @@ -75,7 +104,7 @@ sub get_available_languages my ($file, @files, $hdf, $lang_name); opendir(DIR, $LANGUAGE_DIR) or die ("Language directory ($LANGUAGE_DIR) not accessible!"); - @files = grep { /.*\.hdf$/ } readdir(DIR); + @files = sort grep { /.*\.hdf$/ } readdir(DIR); close(DIR); foreach $file (@files) { @@ -146,6 +175,8 @@ sub get_admin_pw sub render { + &load_selected_language($pagedata); + $pagedata->setValue("PageName","$pagename"); my $pagefile = "$HTML_TEMPLATE_DIR/main.cs"; print "Content-Type: text/html\n\n"; @@ -260,40 +291,10 @@ sub validate_doc_language ################### main ######################### -my $query = new CGI; $pagedata = load_hdf(); -######### temporary language setting? ############ -# the default language can be overriden by the language links in the -# upper right of the page -if ($query->param('weblang')) { - my $weblang = $query->param('weblang'); - if (&validate_language($weblang)) { - # load the data - &load_language_data($pagedata, "$weblang"); - # add the setting to every link - $pagedata->setValue('Data.PostData.weblang', "$weblang"); - } else { - $pagedata->setValue('Data.Warning', 'InvalidLanguage'); - } -} - - -########## select documentation language ########## -if ($query->param('weblang') && &validate_doc_language($query->param('weblang'))) { - # selected web interface language - $pagedata->setValue('Settings.DocLang', "$query->param('weblang')"); -} elsif (&validate_doc_language($LANGUAGE)) { - # configured CryptoBox language - $pagedata->setValue('Settings.DocLang', "$LANGUAGE"); -} else { - # default hardcoded language (english) - $pagedata->setValue('Settings.DocLang', "en"); -} - - # first: check for ssl! if ( ! &check_ssl()) { $pagedata->setValue('Data.Error', 'NoSSL'); diff --git a/scripts/validate.sh b/scripts/validate.sh index f5fc318..deca36c 100755 --- a/scripts/validate.sh +++ b/scripts/validate.sh @@ -38,7 +38,7 @@ function do_series() { [ -d "$VALIDATE_REPORT_DIR/$1" ] && rm -r "$VALIDATE_REPORT_DIR/$1" mkdir -p "$VALIDATE_REPORT_DIR/$1" - find "$VALIDATE_TEST_CASES_DIR/$1" -type d -maxdepth 1 -mindepth 1 | grep -v "/\.[^/]*$" | sort | while read a + find "$VALIDATE_TEST_CASES_DIR/$1" -maxdepth 1 -mindepth 1 -type d | grep -v "/\.[^/]*$" | sort | while read a do do_single "$a" "$VALIDATE_REPORT_DIR/$1" done create_summary "$1" >"$VALIDATE_REPORT_DIR/summary-$1.html" @@ -49,7 +49,7 @@ function create_summary() # parameter: name of test series { cat "$VALIDATE_SUMMARY_TEMPLATE_DIR/header" - find "$VALIDATE_REPORT_DIR/$1" -type f -name \*.desc -maxdepth 1 | sort | while read a + find "$VALIDATE_REPORT_DIR/$1" -maxdepth 1 -type f -name \*.desc | sort | while read a do TESTNAME=$(basename ${a%.desc}) TESTDESCRIPTION=$(cat $a) sed "s#_TESTSERIES_#$1#g; s#_TESTNAME_#$TESTNAME#g; s/_TESTDESCRIPTION_/$TESTDESCRIPTION/" "$VALIDATE_SUMMARY_TEMPLATE_DIR/single_header" @@ -102,7 +102,7 @@ ACTION="--help" case "$ACTION" in list ) - find "$VALIDATE_TEST_CASES_DIR" -type d -maxdepth 1 -mindepth 1 | grep -v "/\.[^/]*$" | sort | while read a + find "$VALIDATE_TEST_CASES_DIR" -maxdepth 1 -mindepth 1 -type d | grep -v "/\.[^/]*$" | sort | while read a do echo $(basename "$a") done ;;