Changeset 6774


Ignore:
Timestamp:
2004-02-12T12:36:04+13:00 (20 years ago)
Author:
jrm21
Message:
  • improved the syntax for portability... the previous stuff didn't work under

zsh. (Now use case ... esac switch statements instead of if [ x == y ])

  • See if the user's terminal has the LANG or LC_ALL environment variables set,

and if so, use those to set the language. (Unfortunately the encoding may be
wrong for our strings)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/setup.bash

    r6763 r6774  
    11# if this file is executed, /bin/sh is used, as we don't start with #!
    22# this should work under ash, bash, zsh, ksh, sh style shells.
    3 gsdllang=en
     3gsdllang=""
     4
     5# see if the shell has any language environment variables set
     6# see locale(7) manpage for this ordering.
     7if test ! -z "$LC_ALL" ; then
     8  gsdllang=$LC_ALL
     9elif test ! -z "$LANG"; then
     10  gsdllang=$LANG
     11fi
     12
     13# note... all our output strings have the charset hard-coded, but
     14# people may be using a different encoding in their terminal. LANG
     15# strings look like "en_NZ.UTF-8". For now this doesn't check encodings
     16# or the _country bit
     17
     18# Our french and spanish strings are currently in iso-8859-1 encoding.
     19
     20case $gsdllang in
     21  fr*|FR*)
     22    gsdllang=fr
     23  ;;
     24  es*|ES*)
     25    gsdllang=es
     26  ;;
     27  ru*|RU*)
     28    gsdllang=ru
     29  ;;
     30  *) # default
     31    gsdllang=en
     32  ;;
     33esac 
    434
    535# make sure we are sourced, and not run
     
    1545
    1646if test -n "$gsdl_not_sourced" ; then
    17   if [ "$gsdllang" == "es" ]; then
     47  case "$gsdllang" in
     48 "es")
    1849    echo "      Error: Asegúrese de compilar este guión, no de ejecutarlo. P. ej.:"
    1950    echo "         $ source setup.bash"
     
    2253    echo "      no"
    2354    echo "         $ ./setup.bash"
    24   elif [ "$gsdllang" == "fr" ]; then
     55  ;;
     56  "fr")
    2557    echo "-- Still coming --"
    26   elif [ "$gsdllang" == "ru" ]; then
     58  ;;
     59  "ru")
    2760    echo "      ïÛÉÂËÁ: õÄÏÓÔÏ×ÅÒØÔÅÓØ × ÉÓÔÏÞÎÉËÅ ÜÔÏÇÏ ÓËÒÉÐÔÁ. îÅ ÉÓÐÏÌÎÑÊÔÅ ÅÇÏ."
    2861    echo "      îÁÐÒÉÍÅÒ:"
     
    3265    echo "      ÎÅÔ"
    3366    echo "         $./setup.bash"
    34   else
     67  ;;
     68  *)
    3569    echo "  Error: Make sure you source this script, not execute it. Eg:"
    3670    echo "      $ source setup.bash"
     
    3973    echo "  not"
    4074    echo "      $ ./setup.bash"
    41   fi
     75  ;;
     76  esac
    4277elif test -n "$GSDLHOME" ; then
    43   if [ "$gsdllang" == "es" ]; then
     78  case "$gsdllang" in
     79  "es")
    4480    echo "¡Su ambiente ya está listo para Greenstone!"
    45   elif [ "$gsdllang" == "fr" ]; then
     81  ;;
     82  "fr")
    4683    echo "Votre environnement est déjà préparé pour Greenstone!"
    47   elif [ "$gsdllang" == "ru" ]; then
     84 ;;
     85  "ru")
    4886    echo "÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÕÖÅ ÎÁÓÔÒÏÅÎÏ ÄÌÑ Greenstone!"
    49   else
     87  ;;
     88  *)
    5089    echo "Your environment is already set up for Greenstone!"
    51   fi
     90  ;;
     91  esac
    5292elif test ! -f setup.bash ; then
    53   if [ "$gsdllang" == "es" ]; then
     93  case "$gsdllang" in
     94    "es")
    5495    echo "Usted debe compilar el guión desde el interior del directorio de inicio"
    5596    echo "de Greenstone."
    56   elif [ "$gsdllang" == "fr" ]; then
     97  ;;
     98  "fr")
    5799    echo "Vous devez trouver la source du script dans le répertoire de base de Greenstone"
    58   elif [ "$gsdllang" == "ru" ]; then
     100  ;;
     101  "ru")
    59102    echo "÷ÁÍ ÎÅÏÂÈÏÄÉÍ ÉÓÔÏÞÎÉË ÓËÒÉÐÔÁ ÉÚ ÂÁÚÏ×ÏÊ ÄÉÒÅËÔÏÒÉÉ Greenstone"
    60   else
     103  ;;
     104  *)
    61105    echo "You must source the script from within the Greenstone home directory"
    62   fi
     106  ;;
     107  esac
    63108else
    64109  GSDLHOME=`pwd`
     
    76121  MANPATH=$MANPATH:$GSDLHOME/packages/mg/man
    77122  export MANPATH
    78   if [ "$gsdllang" == "es" ]; then
    79     echo "Su ambiente ha sido configurado para correr los programas Greenstone."
    80   elif [ "$gsdllang" == "fr" ]; then
    81     echo "Votre environnement a été configuére avec succès pour exécuter Greenstone"
    82   elif [ "$gsdllang" == "ru" ]; then
    83     echo "÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÂÙÌÏ ÕÓÐÅÛÎÏ ÎÁÓÔÒÏÅÎÏ, ÞÔÏÂÙ ÕÓÔÁÎÏ×ÉÔØ Greenstone"
    84   else
    85     echo "Your environment has successfully been set up to run Greenstone"
    86   fi
     123  case "$gsdllang" in
     124    "es")
     125      echo "Su ambiente ha sido configurado para correr los programas Greenstone."
     126    ;;
     127    "fr")
     128      echo "Votre environnement a été configuére avec succès pour exécuter Greenstone"
     129    ;;
     130    "ru")
     131      echo "÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÂÙÌÏ ÕÓÐÅÛÎÏ ÎÁÓÔÒÏÅÎÏ, ÞÔÏÂÙ ÕÓÔÁÎÏ×ÉÔØ Greenstone"
     132    ;;
     133    *)
     134      echo "Your environment has successfully been set up to run Greenstone"
     135    ;;
     136  esac
    87137fi
    88138unset gsdl_not_sourced
Note: See TracChangeset for help on using the changeset viewer.