source: trunk/gsdl/setup.bash@ 6892

Last change on this file since 6892 was 6892, checked in by jrm21, 20 years ago

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)

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1# if this file is executed, /bin/sh is used, as we don't start with #!
2# this should work under ash, bash, zsh, ksh, sh style shells.
3gsdllang=""
4# encoding inputs and outputs
5gsdltoenc=""
6gsdlfromenc=""
7
8# see if the shell has any language environment variables set
9# see locale(7) manpage for this ordering.
10if test ! -z "$LC_ALL" ; then
11 gsdllang="$LC_ALL"
12elif test ! -z "$LANG"; then
13 gsdllang="$LANG"
14fi
15
16
17# note... all our output strings have the charset hard-coded, but
18# people may be using a different encoding in their terminal. LANG
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
27
28# Our french and spanish strings are currently in iso-8859-1 encoding.
29case $gsdllang in
30 fr*|FR*)
31 gsdllang=fr
32 gsdlfromenc="iso-8859-1"
33 ;;
34 es*|ES*)
35 gsdllang=es
36 gsdlfromenc="iso-8859-1"
37 ;;
38 ru*|RU*)
39 gsdllang=ru
40 gsdlfromenc="koi8r"
41 ;;
42 *) # default
43 gsdllang=en
44 gsdlfromenc="iso-8859-1"
45 ;;
46esac
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
57
58# make sure we are sourced, and not run
59
60if test "$0" != "`echo $0 | sed s/setup\.bash//`" ; then
61# if $0 contains "setup.bash" we've been run... $0 is shellname if sourced.
62# One exception is zsh has an option to set it temporarily to the script name
63 if test -z "$ZSH_NAME" ; then
64 # we aren't using zsh
65 gsdl_not_sourced=true
66 fi
67fi
68
69if test -n "$gsdl_not_sourced" ; then
70 case "$gsdllang" in
71 "es")
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
80 ;;
81 "fr")
82eval $gsdliconv <<EOF
83-- Still coming --
84EOF
85 ;;
86 "ru")
87eval $gsdliconv <<EOF
88 ïÛÉÂËÁ: õÄÏÓÔÏ×ÅÒØÔÅÓØ × ÉÓÔÏÞÎÉËÅ ÜÔÏÇÏ ÓËÒÉÐÔÁ. îÅ ÉÓÐÏÌÎÑÊÔÅ ÅÇÏ.
89 îÁÐÒÉÍÅÒ:
90 $ source setup.bash
91 ÉÌÉ
92 $ . ./setup.bash
93 ÎÅÔ
94 $ ./setup.bash
95EOF
96 ;;
97 *)
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
106 ;;
107 esac
108elif test -n "$GSDLHOME" ; then
109 case "$gsdllang" in
110 "es")
111 echo '¡Su ambiente ya está listo para Greenstone!' | eval $gsdliconv
112 ;;
113 "fr")
114 echo 'Votre environnement est déjà préparé pour Greenstone!' | eval $gsdliconv
115 ;;
116 "ru")
117 echo '÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÕÖÅ ÎÁÓÔÒÏÅÎÏ ÄÌÑ Greenstone!' | eval $gsdliconv
118 ;;
119 *)
120 echo 'Your environment is already set up for Greenstone!'
121 ;;
122 esac
123elif test ! -f setup.bash ; then
124 case "$gsdllang" in
125 "es")
126eval $gsdliconv <<EOF
127Usted debe compilar el guión desde el interior del directorio de inicio
128de Greenstone.
129EOF
130 ;;
131 "fr")
132echo 'Vous devez trouver la source du script dans le répertoire de base de Greenstone' | eval $gsdliconv
133 ;;
134 "ru")
135eval $gsdliconv <<EOF
136÷ÁÍ ÎÅÏÂÈÏÄÉÍ ÉÓÔÏÞÎÉË ÓËÒÉÐÔÁ ÉÚ ÂÁÚÏ×ÏÊ ÄÉÒÅËÔÏÒÉÉ Greenstone
137EOF
138 ;;
139 *)
140 echo 'You must source the script from within the Greenstone home directory'
141 ;;
142 esac
143else
144 GSDLHOME=`pwd`
145 export GSDLHOME
146 GSDLOS=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
147 # check for running bash under cygwin
148 if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ;
149 then
150 GSDLOS=windows
151 fi
152 export GSDLOS
153
154 PATH=$PATH:$GSDLHOME/bin/script:$GSDLHOME/bin/$GSDLOS
155 export PATH
156 MANPATH=$MANPATH:$GSDLHOME/packages/mg/man
157 export MANPATH
158 case "$gsdllang" in
159 "es")
160 echo 'Su ambiente ha sido configurado para correr los programas Greenstone.' | eval $gsdliconv
161 ;;
162 "fr")
163 echo 'Votre environnement a été configuére avec succès pour exécuter Greenstone' | eval $gsdliconv
164 ;;
165 "ru")
166eval $gsdliconv <<EOF
167÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÂÙÌÏ ÕÓÐÅÛÎÏ ÎÁÓÔÒÏÅÎÏ, ÞÔÏÂÙ ÕÓÔÁÎÏ×ÉÔØ Greenstone
168EOF
169 ;;
170 *)
171 echo 'Your environment has successfully been set up to run Greenstone'
172 ;;
173 esac
174fi
175unset gsdl_not_sourced
176unset gsdliconv
177unset gsdlfromenc
178unset gsdltoenc
Note: See TracBrowser for help on using the repository browser.