Mercurial > trustbridge
changeset 795:3a9b0c75f5a6
Added i18n code and german l10n to linux installer.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Tue, 15 Jul 2014 13:24:26 +0200 |
parents | fdc15f0cfdd8 |
children | c61acf2a22dc |
files | CMakeLists.txt packaging/getxt-gen-l10n-array.sh packaging/linux-createpackage.sh.in packaging/linux-installer.inc.in packaging/linux-installer.l10n-de |
diffstat | 5 files changed, 164 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/CMakeLists.txt Tue Jul 15 12:03:45 2014 +0200 +++ b/CMakeLists.txt Tue Jul 15 13:24:26 2014 +0200 @@ -121,6 +121,7 @@ configure_file (packaging/create-dist-package.sh.in packaging/create-dist-package.sh @ONLY) configure_file (packaging/linux-createpackage.sh.in packaging/linux-createpackage.sh @ONLY) configure_file (packaging/linux-installer.inc.in packaging/linux-installer.inc @ONLY) +configure_file (packaging/linux-installer.l10n-de packaging/linux-installer.l10n-de COPYONLY) if (ENABLE_PROFILING) configure_file (make-coverage.sh.in make-coverage.sh)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/packaging/getxt-gen-l10n-array.sh Tue Jul 15 13:24:26 2014 +0200 @@ -0,0 +1,57 @@ +# ------------------------------------------------------------------- +# Copyright (C) 2014 by Intevation GmbH +# Author(s): +# Sascha Wilde <wilde@intevation.de> + +# This program is free software under the GNU GPL (>=v2) +# Read the file COPYING coming with the software for details. +# ------------------------------------------------------------------- + +# Extract getxt strings from source and generate an array for usage in +# the script using our getxt function. + +# USAGE: getxt-gen-l10n-array.sh SRC ARRAYNAME ARRAYFILE +# +# Where SRC is the shell script using getxt and ARRAYFILE is +# the file to which the generated array is to be saved. +# +# ARRAYNAME is the name of the associative bash array to generate. +# +# If ARRAYFILE exists, values already defined will be preserved, +# if the MSGID still exists. + +# FIXME: we can't handle quoted quotes: "\"" -- don't use them for +# now... + +declare -a MSGIDS +declare -A L10N + +get_msgids() +{ + while read -r id ; do + MSGIDS+=("$id") + done < <( sed -n 's/.*\(getxt\|fatal\) [^"]*\("[^"]*"\).*/\2/p' "$1" | sort | uniq ) +} + +merge_l10n() +{ + for msgid in "${MSGIDS[@]}" ; do + msg=`grep -F "[${msgid}]" "$1" | sed -n 's/.*="\(.*\)"/\1/p'` + if [ "$msg" ] ; then + L10N["$msgid"]="$msg" + fi + done +} + +write_l10n_array() +{ + echo "$1=(" + for msgid in "${MSGIDS[@]}" ; do + echo " [${msgid}]=\"${L10N[$msgid]}\"" + done + echo ")" +} + +get_msgids "$1" +merge_l10n "$3" +write_l10n_array "$2" >"$3"
--- a/packaging/linux-createpackage.sh.in Tue Jul 15 12:03:45 2014 +0200 +++ b/packaging/linux-createpackage.sh.in Tue Jul 15 13:24:26 2014 +0200 @@ -16,6 +16,8 @@ "@CMAKE_BINARY_DIR@/ui/trustbridge" "@CMAKE_BINARY_DIR@/ui/trustbridge-tray-starter.sh") +L10N_DE_FILE="@CMAKE_BINARY_DIR@/packaging/linux-installer.l10n-de" + # Make installation in TMPDIR, this is what we will put into the # shar-archive. echo "Using $TMPDIR for temporary installation to build installer..." @@ -34,6 +36,7 @@ done sed -i "s/###BINNAMES###/${binnames}/" "$INSTALLER" sed -i "/###SHAR###/r $TMPSHAR" "$INSTALLER" +sed -i "/###L10N_DE###/r $L10N_DE_FILE" "$INSTALLER" chmod +x "$INSTALLER" echo "Cleaning up..."
--- a/packaging/linux-installer.inc.in Tue Jul 15 12:03:45 2014 +0200 +++ b/packaging/linux-installer.inc.in Tue Jul 15 13:24:26 2014 +0200 @@ -29,6 +29,31 @@ [PREFIX]='' ) +declare -A L10N_DE +###L10N_DE### + +getxt() +{ + # Poor mans gettext for l10n completely self contained in one shell + # script. + MSGID="$1" + shift + case ${LANGUAGE:-${LC_ALL:-${LC_MESSAGES:-$LANG}}} in + de*) + if [ "${L10N_DE[$MSGID]}" ] ; then + MSG="${L10N_DE[$MSGID]}" + else + MSG="$MSGID" + fi + ;; + *) + MSG="$MSGID" + ;; + esac + + printf "$MSG" "$@" +} + version() { cat <<EOF @@ -46,11 +71,11 @@ fatal() { - echo "$1" >&2 + getxt "$1" >&2 if [ $DEINSTALL -eq 1 ] ; then - echo "Deinstallation failed." >&2 + getxt "Deinstallation failed.\n" >&2 else - echo "Installation failed." >&2 + getxt "Installation failed.\n" >&2 fi exit 1 } @@ -87,7 +112,7 @@ return 1 ;; *) - echo >&2 "Answer [Y]es or [N]o: " + getxt >&2 "Answer [Y]es or [N]o:\n" esac done } @@ -161,7 +186,7 @@ read_oldinstcfg() { if [ -r "$instcfg_file" ] ; then - echo "Reading '$instcfg_file' ..." + getxt "Reading '%s' ...\n" "$instcfg_file" for key in "${!oldinstcfg[@]}" ; do oldinstcfg[$key]=`sed -n "/$key/s/[^=]*=\(.*\)/\1/p" "$instcfg_file"` done @@ -171,7 +196,7 @@ check_priv() { if [ $SYSINST -eq 1 -a "$UID" -ne 0 ] ; then - fatal "System wide installation requires root privileges!" + fatal "System wide installation requires root privileges!\n" fi } @@ -183,7 +208,7 @@ # long as they are empty. local directory="$1" while [ -d "$directory" -a -z "$(ls 2>/dev/null -A "$directory")" ] ; do - echo "Deleting empty directory '$directory' ..." + getxt "Deleting empty directory '%s' ...\n" "$directory" rmdir "$directory" directory=`dirname "$directory"` done @@ -193,7 +218,7 @@ { for file in "$@" ; do if [ -e "$file" ] ; then - echo "Deleting $file ..." + getxt "Deleting '%s' ...\n" "$file" rm "$file" fi done @@ -236,23 +261,23 @@ local cinst="${oldinstcfg[PREFIX]}/bin/cinst" local certlist=`ls 2>/dev/null -1 ${instdata_path}/list-*.txt | sort -nr | head -n 1` - echo "Uninstalling certificates ..." + getxt "Uninstalling certificates ...\n" if [ "$certlist" ] ; then - echo "Using certificate list '$certlist'." + getxt "Using certificate list '%s'.\n" "$certlist" if [ -x "$cinst" ] ; then "$cinst" "list=$certlist" "choices=uninstall" else - echo >&2 "WARNING: can't execute $cinst for certificate deinstallation." + getxt >&2 "WARNING: can't execute %s for certificate deinstallation.\n" "$cinst" fi else - echo "No certificate list found. Nothing to do." + getxt "No certificate list found. Nothing to do.\n" fi } deinstall_etc() { - echo "Removing cron job ..." + getxt "Removing cron job ...\n" remove_cronjob # FIXME: delete all files created by the application. @@ -260,36 +285,39 @@ "${instcfg_path}/trustbridge-tray-starter.cfg" "$instcfg_file" ) - echo "Removing certificate lists from: ${instdata_path}:" + getxt "Removing certificate lists from: %s:\n" "$instdata_path" rm_files "$instdata_path"/list-*.txt + + getxt "Removing PID file from: %s:\n" "$instdata_path" + rm_files "$instdata_path"/*.pid rm_empty_dirs "$instdata_path" - echo "Removing configuration files:" + getxt "Removing configuration files:\n" rm_files "${tbcfg_files[@]}" rm_empty_dirs "$instcfg_path" - echo "Removing TrustBridge from autostart" + getxt "Removing TrustBridge from autostart\n" rm_files "${autostart_path}/tustbridge.desktop" } deinstall() { if [ "${oldinstcfg[PREFIX]}" ] ; then - echo "Really deinstall TrustBridge from '${oldinstcfg[PREFIX]}'? [y/n]" + getxt "Really deinstall TrustBridge from '%s'? [y/n]\n" "${oldinstcfg[PREFIX]}" yorn || exit 0 deinstall_certs local deinstdir="${oldinstcfg[PREFIX]}/bin" - echo "Deinstalling from '${oldinstcfg[PREFIX]}'." + getxt "Deinstalling from '%s'.\n" "${oldinstcfg[PREFIX]}" for file in $BINNAMES ; do local path="${deinstdir}/$file" - echo "Deleting '$path' ..." - rm "$path" || echo >&2 "WARNING: Could not delete: '$path'!" + getxt "Deleting '%s' ...\n" "$path" + rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path" done rm_empty_dirs "$deinstdir" deinstall_etc - echo "Deinstallation finished." + getxt "Deinstallation finished.\n" else - echo "No current installation found! No harm done." + getxt "No current installation found! No harm done.\n" fi } @@ -312,7 +340,7 @@ # respected with regards to autostart. if [ ! -d "${autostart_path}" ]; then install -d "${autostart_path}" || \ - fatal "Failed to create autostart directory: '${autostart_path}'" + fatal "Failed to create autostart directory: '%s'\n" "$autostart_path" fi write_autostart "${autostart_path}/tustbridge.desktop" @@ -345,12 +373,12 @@ if [ "${oldinstcfg[PREFIX]}" ] ; then inst_default_prefix="${oldinstcfg[PREFIX]}" - echo "An existing installation (v${oldinstcfg[VERSION]}) was detected!" - echo "It is HIGHLY RECOMMENDED to accept the default prefix" - echo "to update the current installation." - echo "For a new prefix you should deinstall first!" + getxt "An existing installation (v%s) was detected!\n" "${oldinstcfg[VERSION]}" + getxt "It is HIGHLY RECOMMENDED to accept the default prefix\n" + getxt "to update the current installation.\n" + getxt "For a new prefix you should deinstall first!\n" fi - echo -n "Select installation prefix for TrustBridge [${inst_default_prefix}]: " + getxt "Select installation prefix for TrustBridge [%s]: " "${inst_default_prefix}" read -e instcfg[PREFIX] [ -z "${instcfg[PREFIX]}" ] && instcfg[PREFIX]="${inst_default_prefix}" @@ -359,18 +387,18 @@ if [ "${oldinstcfg[PREFIX]}" -a \ "${instcfg[PREFIX]}" != "${oldinstcfg[PREFIX]}" -a \ $FORCE -ne 1 ] ; then - fatal "Prefix differs from current installation (${oldinstcfg[PREFIX]}). Aborting!" + fatal "Prefix differs from current installation (%s). Aborting!\n" "${oldinstcfg[PREFIX]}" fi fi -echo "Installing to '${instcfg[PREFIX]}':" +getxt "Installing to '%s':\n" "${instcfg[PREFIX]}" if [ ! -d "${instcfg[PREFIX]}" ] ; then - echo "creating installation directory ..." - install -d "${instcfg[PREFIX]}" || fatal "Could not create '${instcfg[PREFIX]}'!" + getxt "creating installation directory ...\n" + install -d "${instcfg[PREFIX]}" || fatal "Could not create '%s'!\n" "${instcfg[PREFIX]}" fi -echo "unpacking files ..." +getxt "unpacking files ...\n" cd "${instcfg[PREFIX]}" set +u @@ -380,16 +408,16 @@ ###SHAR### # ---------------------------------------------------------------------- -echo "Preparing trustbridge-tray-starter ..." +getxt "Preparing trustbridge-tray-starter ...\n" sed -i "/^PREFIX=/c\PREFIX='${instcfg[PREFIX]}'" \ "${instcfg[PREFIX]}/bin/trustbridge-tray-starter.sh" -echo "Setting up cronjob ..." +getxt "Setting up cronjob ...\n" setup_cronjob -echo "Setting up autostart ..." +getxt "Setting up autostart ...\n" setup_autostart -echo "Writing installation configuration to: $instcfg_file ..." +getxt "Writing installation configuration to: %s ...\n" "$instcfg_file" write_instcfg exit 0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/packaging/linux-installer.l10n-de Tue Jul 15 13:24:26 2014 +0200 @@ -0,0 +1,38 @@ +L10N_DE=( + ["An existing installation (v%s) was detected!\n"]="Es wurde eine vorhandene Installation (v%s) gefunden!\n" + ["Answer [Y]es or [N]o:\n"]="Bitte [J]a oder [N]ein eingeben:\n" + ["Could not create '%s'!\n"]="Konnte '%s' nicht erstellen!\n" + ["Deinstallation failed.\n"]="Deinstallation fehlgeschlagen.\n" + ["Deinstallation finished.\n"]="Deinstallation abgeschlossen.\n" + ["Deinstalling from '%s'.\n"]="Deinstalliere aus '%s'.\n" + ["Deleting '%s' ...\n"]="Lösche '%s' ...\n" + ["Deleting empty directory '%s' ...\n"]="Lösche das leere Verzeichnis '%s' ...\n" + ["Failed to create autostart directory: '%s'\n"]="Konnte das autostart-Verzeichnis '%s' nicht erstellen\n" + ["For a new prefix you should deinstall first!\n"]="Um einen neuen Installations-Pfad zu verwenden bitte erst deinstallieren!\n" + ["Installation failed.\n"]="Installation fehlgeschlagen.\n" + ["Installing to '%s':\n"]="Installiere in '%s':\n" + ["It is HIGHLY RECOMMENDED to accept the default prefix\n"]="Es wird DRINGEND EMPFOHLEN die Vorgabe zu akzeptieren\n" + ["No certificate list found. Nothing to do.\n"]="Keine Zertifikatsliste gefunden. Es muss nichts getan werden.\n" + ["No current installation found! No harm done.\n"]="Keine vorhandene Installation gefunden!\n" + ["Prefix differs from current installation (%s). Aborting!\n"]="Installations-Pfad weicht von vorhandener Installation (%s) ab.\nVorgang abgebrochen!\n" + ["Preparing trustbridge-tray-starter ...\n"]="Bereite trustbridge-tray-starter vor ...\n" + ["Reading '%s' ...\n"]="Lese '%s' ...\n" + ["Really deinstall TrustBridge from '%s'? [y/n]\n"]="Soll TrustBridge wirklich aus '%s' deinstalliert werden? [j/n]\n" + ["Removing PID file from: %s:\n"]="Entferne PID-File aus: %s\n" + ["Removing TrustBridge from autostart\n"]="Entferne TrustBridge aus autostart\n" + ["Removing certificate lists from: %s:\n"]="Entferne Zertifikatsliste aus: %s\n" + ["Removing configuration files:\n"]="Entferne Konfigurationsdateien:\n" + ["Removing cron job ...\n"]="Entferne den Cron-Job ...\n" + ["Select installation prefix for TrustBridge [%s]: "]="Installations-Pfad für TrustBridge [%s]: " + ["Setting up autostart ...\n"]="Konfiguriere autostart ...\n" + ["Setting up cronjob ...\n"]="Konfiguriere den Cron-Job ...\n" + ["System wide installation requires root privileges!\n"]="Für die systemweite Installation werden root-Rechte benötigt!\n" + ["Uninstalling certificates ...\n"]="Deinstalliere Zertifikate ...\n" + ["Using certificate list '%s'.\n"]="Die Zertifikatsliste '%s' wird verwendet.\n" + ["WARNING: Could not delete: '%s'!\n"]="WARNUNG: Konnte '%s' nicht löschen!\n" + ["WARNING: can't execute %s for certificate deinstallation.\n"]="WARNUNG: '%s' kann nicht zum deinstallieren der Zertifikate ausgeführt werden.\n" + ["Writing installation configuration to: %s ...\n"]="Schreibe Installationskonfiguration nach: %s ...\n" + ["creating installation directory ...\n"]="lege das Installations-Verzeichnis an ...\n" + ["to update the current installation.\n"]="um die vorhandene Installation zu aktualisieren.\n" + ["unpacking files ...\n"]="Entpacke Dateien ...\n" +)