Changeset 6892 for trunk/gsdl/setup.bash


Ignore:
Timestamp:
2004-02-25T17:09:55+13:00 (20 years ago)
Author:
jrm21
Message:

use iconv (if it is installed) to convert strings to the correct encoding,
if an encoding is set in the correct environment variables (LC_ALL, LANG, etc)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/setup.bash

    r6820 r6892  
    22# this should work under ash, bash, zsh, ksh, sh style shells.
    33gsdllang=""
     4# encoding inputs and outputs
     5gsdltoenc=""
     6gsdlfromenc=""
    47
    58# see if the shell has any language environment variables set
    69# see locale(7) manpage for this ordering.
    710if test ! -z "$LC_ALL" ; then
    8   gsdllang=$LC_ALL
     11  gsdllang="$LC_ALL"
    912elif test ! -z "$LANG"; then
    10   gsdllang=$LANG
     13  gsdllang="$LANG"
    1114fi
     15
    1216
    1317# note... all our output strings have the charset hard-coded, but
    1418# 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
     19# strings look like "en_NZ.UTF-8".
     20
     21# Determine the requested output encoding
     22case $gsdllang in
     23  *.*)
     24    gsdltoenc=`echo $gsdllang | sed 's/.*\.//'`
     25    ;;
     26esac
    1727
    1828# Our french and spanish strings are currently in iso-8859-1 encoding.
    19 
    2029case $gsdllang in
    2130  fr*|FR*)
    2231    gsdllang=fr
     32    gsdlfromenc="iso-8859-1"
    2333  ;;
    2434  es*|ES*)
    2535    gsdllang=es
     36    gsdlfromenc="iso-8859-1"
    2637  ;;
    2738  ru*|RU*)
    2839    gsdllang=ru
     40    gsdlfromenc="koi8r"
    2941  ;;
    3042  *) # default
    3143    gsdllang=en
     44    gsdlfromenc="iso-8859-1"
    3245  ;;
    3346esac 
     47
     48# "iconv" is the program for converting text between encodings.
     49gsdliconv=`which iconv 2>/dev/null`
     50if test $? -ne 0 || test -z "$gsdlfromenc" || test -z "$gsdltoenc"; then
     51# we can't convert encodings from some reason
     52  gsdliconv="cat"
     53else
     54# add the encodings
     55  gsdliconv="$gsdliconv -f $gsdlfromenc -t $gsdltoenc"
     56fi
    3457
    3558# make sure we are sourced, and not run
     
    4770  case "$gsdllang" in
    4871 "es")
    49     echo '      Error: Asegúrese de compilar este guión, no de ejecutarlo. P. ej.:'
    50     echo '         $ source setup.bash'
    51     echo '      o'
    52     echo '         $ . ./setup.bash'
    53     echo '      no'
    54     echo '         $ ./setup.bash'
     72eval $gsdliconv <<EOF
     73      Error: Asegúrese de compilar este guión, no de ejecutarlo. P. ej.:
     74         $ source setup.bash
     75      o
     76         $ . ./setup.bash
     77      no
     78         $ ./setup.bash
     79EOF
    5580  ;;
    5681  "fr")
    57     echo '-- Still coming --'
     82eval $gsdliconv <<EOF
     83-- Still coming --
     84EOF
    5885  ;;
    5986  "ru")
    60     echo '      ïÛÉÂËÁ: õÄÏÓÔÏ×ÅÒØÔÅÓØ × ÉÓÔÏÞÎÉËÅ ÜÔÏÇÏ ÓËÒÉÐÔÁ. îÅ ÉÓÐÏÌÎÑÊÔÅ ÅÇÏ.'
    61     echo '      îÁÐÒÉÍÅÒ:'
    62     echo '         $ source setup.bash'
    63     echo '      ÉÌÉ'
    64     echo '         $../setup.bash'
    65     echo '      ÎÅÔ'
    66     echo '         $./setup.bash'
     87eval $gsdliconv <<EOF
     88      ïÛÉÂËÁ: õÄÏÓÔÏ×ÅÒØÔÅÓØ × ÉÓÔÏÞÎÉËÅ ÜÔÏÇÏ ÓËÒÉÐÔÁ. îÅ ÉÓÐÏÌÎÑÊÔÅ ÅÇÏ.
     89      îÁÐÒÉÍÅÒ:
     90         $ source setup.bash
     91      ÉÌÉ
     92         $ . ./setup.bash
     93      ÎÅÔ
     94         $ ./setup.bash
     95EOF
    6796  ;;
    6897  *)
    69     echo '  Error: Make sure you source this script, not execute it. Eg:'
    70     echo '      $ source setup.bash'
    71     echo '  or'
    72     echo '      $ . ./setup.bash'
    73     echo '  not'
    74     echo '      $ ./setup.bash'
     98eval $gsdliconv <<EOF
     99    Error: Make sure you source this script, not execute it. Eg:
     100        $ source setup.bash
     101    or
     102        $ . ./setup.bash
     103    not
     104        $ ./setup.bash
     105EOF
    75106  ;;
    76107  esac
     
    78109  case "$gsdllang" in
    79110  "es")
    80     echo '¡Su ambiente ya está listo para Greenstone!'
     111    echo '¡Su ambiente ya está listo para Greenstone!' | eval $gsdliconv
    81112  ;;
    82113  "fr")
    83     echo 'Votre environnement est déjà préparé pour Greenstone!'
     114    echo 'Votre environnement est déjà préparé pour Greenstone!' | eval $gsdliconv
    84115 ;;
    85116  "ru")
    86     echo '÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÕÖÅ ÎÁÓÔÒÏÅÎÏ ÄÌÑ Greenstone!'
     117    echo '÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÕÖÅ ÎÁÓÔÒÏÅÎÏ ÄÌÑ Greenstone!' | eval $gsdliconv
    87118  ;;
    88119  *)
     
    93124  case "$gsdllang" in
    94125    "es")
    95     echo 'Usted debe compilar el guión desde el interior del directorio de inicio'
    96     echo 'de Greenstone.'
     126eval $gsdliconv <<EOF
     127Usted debe compilar el guión desde el interior del directorio de inicio
     128de Greenstone.
     129EOF
    97130  ;;
    98131  "fr")
    99     echo 'Vous devez trouver la source du script dans le répertoire de base de Greenstone'
     132echo 'Vous devez trouver la source du script dans le répertoire de base de Greenstone' | eval $gsdliconv
    100133  ;;
    101134  "ru")
    102     echo '÷ÁÍ ÎÅÏÂÈÏÄÉÍ ÉÓÔÏÞÎÉË ÓËÒÉÐÔÁ ÉÚ ÂÁÚÏ×ÏÊ ÄÉÒÅËÔÏÒÉÉ Greenstone'
     135eval $gsdliconv <<EOF
     136÷ÁÍ ÎÅÏÂÈÏÄÉÍ ÉÓÔÏÞÎÉË ÓËÒÉÐÔÁ ÉÚ ÂÁÚÏ×ÏÊ ÄÉÒÅËÔÏÒÉÉ Greenstone
     137EOF
    103138  ;;
    104139  *)
     
    123158  case "$gsdllang" in
    124159    "es")
    125       echo 'Su ambiente ha sido configurado para correr los programas Greenstone.'
     160      echo 'Su ambiente ha sido configurado para correr los programas Greenstone.' | eval $gsdliconv
    126161    ;;
    127162    "fr")
    128       echo 'Votre environnement a été configuére avec succès pour exécuter Greenstone'
     163      echo 'Votre environnement a été configuére avec succès pour exécuter Greenstone' | eval $gsdliconv
    129164    ;;
    130165    "ru")
    131       echo '÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÂÙÌÏ ÕÓÐÅÛÎÏ ÎÁÓÔÒÏÅÎÏ, ÞÔÏÂÙ ÕÓÔÁÎÏ×ÉÔØ Greenstone'
     166eval $gsdliconv <<EOF
     167÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÂÙÌÏ ÕÓÐÅÛÎÏ ÎÁÓÔÒÏÅÎÏ, ÞÔÏÂÙ ÕÓÔÁÎÏ×ÉÔØ Greenstone
     168EOF
    132169    ;;
    133170    *)
     
    137174fi
    138175unset gsdl_not_sourced
     176unset gsdliconv
     177unset gsdlfromenc
     178unset gsdltoenc
Note: See TracChangeset for help on using the changeset viewer.