Rev 16 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 16 | Rev 288 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #!/bin/bash
|
1 | #!/bin/bash
|
2 | 2 | ||
3 | APPNAME="EazyTranslator" |
3 | appname="EazyTranslator" |
4 | APPVER="0.97a" |
4 | appver="0.97a" |
5 | APPFILENAME=`basename $0` |
5 | appfilename=$(readlink $(basename "$0")) |
6 | APPFILEDIR=`echo $0 | sed 's/'$APPFILENAME$'//'` |
6 | [ -n "$appfilename" ] && appfiledir=$(echo "$0" | sed "s/$appfilename\$//") |
7 | 7 | ||
8 | # dictionary file
|
8 | # dictionary file
|
9 | DICT="$TRANSLATE_DIR" |
9 | dict="$TRANSLATE_DIR" |
10 | if [ -z "$DICT" ]; then DICT=$APPFILEDIR ; fi |
10 | [ -z "$dict" ] && dict=$appfiledir |
11 | 11 | ||
12 | # delimiter name (for help page only) and character (string) for separating original expression
|
12 | # delimiter name (for help page only) and character (string) for separating original expression
|
13 | # and translation in dictionary file
|
13 | # and translation in dictionary file
|
14 | DELIMITER_NAME="colon" |
14 | delimiter_name="colon" |
15 | DELIMITER=":" |
15 | delimiter=":" |
16 | 16 | ||
17 | # all help on a single page
|
17 | # all help on a single page
|
18 | SINGLE_PAGE=0 |
18 | single_page=0 |
19 | 19 | ||
20 | # bell character
|
20 | # bell character
|
21 | CH_SOUND="" |
21 | ch_sound="" |
22 | CH_SOUND_ON=$'\a' |
22 | ch_sound_on=$'\a' |
23 | 23 | ||
24 | RESULT="" |
24 | result="" |
25 | 25 | ||
26 | function title { |
26 | title() { |
27 | if [ $SINGLE_PAGE -eq 0 ]; then clear ; fi |
27 | #[ $single_page -eq 0 ] && clear
|
28 | echo
|
28 | echo " |
29 | echo $APPNAME" "$APPVER" - Stream editor to use and to manage dictionary files" |
29 | $appname $appver - Stream editor to use and to manage dictionary files
|
30 | echo "Requires 'basename', 'grep' and 'sed', optionally 'sort' and 'mktemp' in PATH" |
30 | Requires 'basename', 'grep' and 'sed', optionally 'sort' and 'mktemp' in PATH
|
31 | echo
|
31 | "
|
32 | }
|
32 | }
|
33 | 33 | ||
34 | function copyright { |
34 | copyright() { |
35 | echo "Copyright (C) 2001 Thomas Lahn (webmaster@PointedEars.de)" |
35 | echo "Copyright (C) 2001 Thomas Lahn (webmaster@PointedEars.de) |
36 | echo "Be sure to have 'easyTrans' or similar in mail subject line for fast response." |
36 | Be sure to have 'easyTrans' or similar in mail subject line for fast response.
|
37 | echo
|
37 | "
|
38 | }
|
38 | }
|
39 | 39 | ||
40 | function pause { |
40 | pause() { |
41 | if [ "$1" == "c" ]; then |
41 | if [ "$1" == "c" ]; then |
42 | echo "Hit RETURN to continue..." |
42 | echo "Hit RETURN to continue..." |
43 | else
|
43 | else
|
44 | echo "Hit RETURN for the next page" |
44 | echo "Hit RETURN for the next page" |
45 | fi
|
45 | fi
|
46 | read
|
46 | read
|
47 | }
|
47 | }
|
48 | 48 | ||
49 | function copying { |
49 | copying() { |
50 | title |
50 | title |
51 | copyright |
51 | copyright |
52 | echo "This program is free software; you can redistribute it and/or modify" |
52 | echo "This program is free software; you can redistribute it and/or modify |
53 | echo "it under the terms of the GNU General Public License as published by" |
53 | it under the terms of the GNU General Public License as published by
|
54 | echo "the Free Software Foundation; either version 2 of the License, or" |
54 | the Free Software Foundation; either version 2 of the License, or
|
55 | echo "(at your option) any later version." |
55 | (at your option) any later version.
|
56 | echo
|
56 | |
57 | echo "This program is distributed in the hope that it will be useful," |
57 | This program is distributed in the hope that it will be useful,
|
58 | echo "but WITHOUT ANY WARRANTY; without even the implied warranty of" |
58 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
59 | echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" |
59 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
60 | echo "GNU General Public License for more details." |
60 | GNU General Public License for more details.
|
61 | echo
|
61 | |
62 | echo "You should have received a copy of the GNU General Public License" |
62 | You should have received a copy of the GNU General Public License
|
63 | echo "along with this program (COPYING file); if not, write to the" |
63 | along with this program (COPYING file); if not, write to the
|
64 | echo "Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA." |
64 | Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
65 | echo
|
65 | "
|
66 | }
|
66 | }
|
67 | 67 | ||
68 | function cmdHelp { |
68 | cmdHelp() { |
69 | title |
69 | title |
70 | echo $APPFILENAME" EXPRESSION DICTIONARY [OPTIONS]" |
70 | echo "$appfilename EXPRESSION DICTIONARY [OPTIONS] |
71 | echo
|
71 | |
72 | echo "Tries to translate EXPRESSION looking up DICTIONARY and writes the result" |
72 | Tries to translate EXPRESSION looking up DICTIONARY and writes the result
|
73 | echo "to standard output (stdout) in a single line followed by a newline (\n)." |
- | |
74 | echo
|
73 | |
75 | echo "Environment:" |
74 | Environment:
|
76 | echo
|
75 | |
77 | echo "TRANSLATE_DIR Dictionary folder root (absolute path '/')" |
76 | TRANSLATE_DIR Dictionary folder root (absolute path '/')"
|
78 | if [ -n "$TRANSLATE_DIR" ]; then |
77 | if [ -n "$TRANSLATE_DIR" ]; then |
79 | local INVALID_PATH=" -- INVALID PATH!" |
78 | local INVALID_PATH=" -- INVALID PATH!" |
80 | local INVALID_FORMAT=" -- INVALID FORMAT!" |
79 | local INVALID_FORMAT=" -- INVALID FORMAT!" |
81 | # : AutoCorrect performed!
|
80 | # : AutoCorrect performed!
|
82 | local INVALID_MSG="" |
81 | local INVALID_MSG="" |
83 | if [ ! -e $TRANSLATE_DIR ]; then |
82 | if [ ! -e $TRANSLATE_DIR ]; then |
84 | INVALID_MSG=$INVALID_PATH |
83 | INVALID_MSG=$INVALID_PATH |
85 | else
|
84 | else
|
86 | local GREPRES=`echo $TRANSLATE_DIR | grep -e "\/$"` |
85 | local GREPRES=$(echo $TRANSLATE_DIR | grep -e "\/$") |
87 | if [ -z "$GREPRES" ]; then INVALID_MSG=$INVALID_FORMAT ; fi |
86 | [ -z "$GREPRES" ] && INVALID_MSG=$INVALID_FORMAT |
88 | fi
|
87 | fi
|
89 | echo " (currently '"$TRANSLATE_DIR"'"$INVALID_MSG")" |
88 | echo " (currently '"$TRANSLATE_DIR"'"$INVALID_MSG")" |
90 | #if [ "$INVALID_MSG" == "$INVALID_FORMAT" ]; then
|
89 | #if [ "$INVALID_MSG" == "$INVALID_FORMAT" ]; then
|
91 | #export TRANSLATE_DIR=$TRANSLATE_DIR"/"
|
90 | #export TRANSLATE_DIR=$TRANSLATE_DIR"/"
|
92 | #set -a
|
91 | #set -a
|
93 | #fi
|
92 | #fi
|
94 | fi
|
93 | fi
|
- | 94 | echo "\ |
|
95 | echo " If undefined, this is the program directory" |
95 | If undefined, this is the program directory
|
96 | echo " (currently '"$APPFILEDIR"')." |
96 | (currently '$appfiledir').
|
97 | echo "TRANSLATE_OPTIONS Default options to overwrite command-line options" |
97 | TRANSLATE_OPTIONS Default options to overwrite command-line options"
|
98 | if [ -n "$TRANSLATE_OPTIONS" ]; then |
98 | if [ -n "$TRANSLATE_OPTIONS" ]; then |
99 | echo " (currently '"$TRANSLATE_OPTIONS"')" |
99 | echo " (currently '"$TRANSLATE_OPTIONS"')" |
100 | fi
|
100 | fi
|
101 | echo
|
101 | echo " |
102 | echo "Arguments:" |
102 | Arguments:
|
103 | echo
|
103 | |
104 | echo "EXPRESSION Word or (double-quoted) phrase to be translated" |
104 | EXPRESSION Word or (double-quoted) phrase to be translated
|
105 | echo "DICTIONARY Path of dictionary file relative to TRANSLATE_DIR" |
105 | DICTIONARY Path of dictionary file relative to TRANSLATE_DIR
|
106 | echo
|
106 | "
|
107 | if [ $SINGLE_PAGE -eq 0 ]; then pause "c" ; fi |
107 | [ $single_page -eq 0 ] && pause "c" |
- | 108 | echo "\ |
|
108 | echo "Translation OPTIONS:" |
109 | Translation OPTIONS:
|
109 | echo " -b, --brackets If not in DICTIONARY, writes given WORD or EXPRESSION" |
110 | -b, --brackets If not in DICTIONARY, writes given WORD or EXPRESSION
|
110 | echo " as [WORD] or [EXPRESSION]." |
111 | as [WORD] or [EXPRESSION].
|
111 | echo " -m, --messages Return error messages instead of null-strings." |
112 | -m, --messages Return error messages instead of null-strings.
|
112 | echo " -p, --phrase Translate EXPRESSION as entire phrase. If not given," |
113 | -p, --phrase Translate EXPRESSION as entire phrase. If not given,
|
113 | echo " each WORD of EXPRESSION is translated seperately." |
114 | each WORD of EXPRESSION is translated seperately.
|
114 | echo " -r, --reverse Perform reverse translation. Recommended only if" |
115 | -r, --reverse Perform reverse translation. Recommended only if
|
115 | echo " no appropriate dictionary file for vice-versa translation is" |
116 | no appropriate dictionary file for vice-versa translation is
|
116 | echo " available and -p is also used." |
117 | available and -p is also used.
|
117 | echo " -s, --sound Beep on fatal errors." |
118 | -s, --sound Beep on fatal errors.
|
118 | echo " -v, --verbose Display flow of operation. Includes -m behavior." |
119 | -v, --verbose Display flow of operation. Includes -m behavior.
|
119 | echo " -z, --zero Return not translatable tokens as null-strings." |
120 | -z, --zero Return not translatable tokens as null-strings.
|
120 | echo " Overwrites -b." |
121 | Overwrites -b.
|
121 | echo
|
122 | "
|
122 | if [ $SINGLE_PAGE -eq 0 ]; then pause "c" ; fi |
123 | [ $single_page -eq 0 ] && pause "c" |
- | 124 | echo "\ |
|
123 | echo $APPFILENAME" EXPRESSION DICTIONARY COMMAND TRANSLATION [INFO] [OPTIONS]" |
125 | $appfilename EXPRESSION DICTIONARY COMMAND TRANSLATION [INFO] [OPTIONS]
|
124 | echo $APPFILENAME" COMMAND DICTIONARY [INFO] [OPTIONS]" |
126 | $appfilename COMMAND DICTIONARY [INFO] [OPTIONS]
|
125 | echo
|
127 | |
126 | echo "Dictionary file COMMANDs:" |
128 | Dictionary file COMMANDs:
|
127 | echo " -a, --add If not in DICTIONARY, add EXPRESSION with TRANSLATION" |
129 | -a, --add If not in DICTIONARY, add EXPRESSION with TRANSLATION
|
128 | echo " to DICTIONARY and write TRANSLATION." |
130 | to DICTIONARY and write TRANSLATION.
|
129 | echo " If DICTIONARY not exists, create the file with INFO" |
131 | If DICTIONARY not exists, create the file with INFO
|
130 | echo " and add the entry; if INFO is a null-string," |
132 | and add the entry; if INFO is a null-string,
|
131 | echo " default INFO is added, containing program version," |
133 | default INFO is added, containing program version,
|
132 | echo " user name and timestamp. Requires 'sort'." |
134 | user name and timestamp. Requires 'sort'.
|
133 | echo " -ai, --addinfo Add information data INFO to DICTIONARY." |
135 | -ai, --addinfo Add information data INFO to DICTIONARY.
|
134 | echo " Must be used as first argument." |
136 | Must be used as first argument.
|
135 | echo " -c, --create Create new DICTIONARY with INFO (see -a)." |
137 | -c, --create Create new DICTIONARY with INFO (see -a).
|
136 | echo " Existing files are replaced. Must be used as first argument." |
138 | Existing files are replaced. Must be used as first argument.
|
- | 139 | ||
137 | echo " -d, --delete If used with EXPRESSION and DICTIONARY, remove EXPRESSION" |
140 | -d, --delete If used with EXPRESSION and DICTIONARY, remove EXPRESSION
|
138 | echo " from DICTIONARY instead of translating." |
141 | from DICTIONARY instead of translating.
|
139 | echo " If used as first argument, delete DICTIONARY." |
142 | If used as first argument, delete DICTIONARY.
|
140 | echo " -i, --info Display information about DICTIONARY." |
143 | -i, --info Display information about DICTIONARY.
|
141 | echo " Must be used as first argument." |
144 | Must be used as first argument.
|
142 | echo
|
145 | "
|
143 | if [ $SINGLE_PAGE -eq 0 ]; then pause "c" ; fi |
146 | [ $single_page -eq 0 ] && pause "c" |
- | 147 | echo "\ |
|
144 | echo " -o, --overwrite Like -a but overwrite a contained translation of" |
148 | -o, --overwrite Like -a but overwrite a contained translation of
|
145 | echo " EXPRESSION with TRANSLATION without question." |
149 | EXPRESSION with TRANSLATION without question.
|
146 | echo " Additionally requires 'mktemp'." |
150 | Additionally requires 'mktemp'.
|
147 | echo " -R, --repair Repair DICTIONARY instead of translating. Requires 'mktemp'." |
151 | -R, --repair Repair DICTIONARY instead of translating. Requires 'mktemp'.
|
148 | echo " Info data is be kept but invalid entries are removed." |
152 | Info data is be kept but invalid entries are removed.
|
149 | echo " USE WITH CAUTION!" |
153 | USE WITH CAUTION!
|
150 | echo " -s, --sort Sort DICTIONARY instead of translating. Requires 'sort'." |
154 | -s, --sort Sort DICTIONARY instead of translating. Requires 'sort'.
|
151 | echo " Includes --sound when used with -v." |
155 | Includes --sound when used with -v.
|
152 | echo " Must be used as first argument." |
156 | Must be used as first argument.
|
153 | echo
|
157 | "
|
154 | if [ $SINGLE_PAGE -eq 0 ]; then pause "c" ; fi |
158 | [ $single_page -eq 0 ] && pause "c" |
- | 159 | echo "\ |
|
155 | echo $APPFILENAME" OPTION [OPTION]" |
160 | $appfilename OPTION [OPTION]
|
156 | echo
|
161 | |
157 | echo "Help page OPTIONs:" |
162 | Help page OPTIONs:
|
158 | echo " --1 Display help on one page (without 'clear' and user input)." |
163 | --1 Display help on one page (without 'clear' and user input).
|
159 | echo " Useful with redirection " |
164 | Useful with redirection
|
160 | echo " (try '"$APPFILENAME" --1 --? > translate.doc.txt')." |
165 | (try '"$appfilename" --1 --? > translate.doc.txt'). |
161 | echo " Must be given before all other help page options." |
166 | Must be given before all other help page options.
|
162 | echo " --a, --about Display information about the program." |
167 | --a, --about Display information about the program.
|
163 | echo " --c, --cmd Display this help page." |
168 | --c, --cmd Display this help page.
|
164 | echo " --d, --dict Display help about dictionary files." |
169 | --d, --dict Display help about dictionary files.
|
165 | echo " --dev, --emp Display special information for developers and employers." |
170 | --dev, --emp Display special information for developers and employers.
|
166 | echo " --x, --example Display example." |
171 | --x, --example Display example.
|
167 | echo " --?, --help Display all help pages." |
172 | --?, --help Display all help pages.
|
168 | echo
|
173 | "
|
169 | }
|
174 | }
|
170 | 175 | ||
171 | function example { |
176 | example() { |
172 | title |
177 | title |
173 | echo "EXAMPLE: If you would like to translate the English words 'a few' into German," |
178 | echo "EXAMPLE: If you would like to translate the English words 'a few' into German, |
174 | echo
|
179 | |
175 | echo " "$APPFILENAME" ''a few'' en-de" |
180 | $appfilename 'a few' en-de
|
176 | echo
|
181 | |
177 | echo "should write the German words" |
182 | should write the German words
|
178 | echo
|
183 | |
179 | echo " ein(e) wenig(e)\n" |
184 | ein(e) wenig(e)\n
|
180 | echo
|
185 | |
181 | echo "(without indent) to stdout if the echo dictionary file 'en-de' contains" |
186 | (without indent) to stdout if the echo dictionary file 'en-de' contains
|
182 | echo "a correct entry for it (see next page). You may also translate it as" |
187 | a correct entry for it (see next page). You may also translate it as
|
183 | echo "entire phrase (which seems to make more sense here):" |
188 | entire phrase (which seems to make more sense here):
|
184 | echo
|
189 | |
185 | echo " "$APPFILENAME" ''a few'' en-de -p" |
190 | $appfilename 'a few' en-de -p
|
186 | echo
|
191 | |
187 | echo "should instead write the German word 'einige\n'" |
192 | should instead write the German word 'einige\n'
|
188 | echo "(replace '' in input with the double-quote character)." |
193 | (replace '' in input with the double-quote character).
|
- | 194 | ||
189 | echo
|
195 | "
|
190 | }
|
196 | }
|
191 | 197 | ||
192 | function dictHelp { |
198 | dictHelp() { |
193 | title |
199 | title |
- | 200 | echo "\ |
|
194 | echo "DICTIONARY FILES:" |
201 | DICTIONARY FILES:
|
195 | echo "You may create/improve dictionary files to be used with "$APPNAME |
202 | You may create/improve dictionary files to be used with $appname
|
196 | echo "of your own. Translation data must match the following expression:" |
203 | of your own. Translation data must match the following expression:
|
197 | echo
|
204 | |
198 | echo "#"$DELIMITER"File description displayed when option -i is used\n[#"$DELIMITER"File description\n]" |
205 | #${delimiter}File description displayed when option -i is used\\n[#${delimiter}File description\\n]
|
199 | echo "[Expression"$DELIMITER"translation\n[Next expression"$DELIMITER"next translation\n]]" |
206 | [Expression"$delimiter"translation\\n[Next expression"$delimiter"next translation\\n]] |
200 | echo "Last expression"$DELIMITER"last translation\z" |
207 | Last expression"$delimiter"last translation\z |
201 | echo
|
208 | |
202 | echo "Parts enclosed in rectangle brackets are optional. The "$DELIMITER_NAME" ("$DELIMITER") is to be used" |
209 | Parts enclosed in rectangle brackets are optional. The $delimiter_name ($delimiter) is to be used
|
203 | echo "as delimiter character between original and translated expression only." |
210 | as delimiter character between original and translated expression only.
|
204 | echo "Dictionary file names should contain common language identifiers separated" |
211 | Dictionary file names should contain common language identifiers separated
|
205 | echo "by a dash (such as 'en-de.dic' for an English-German dictionary file)." |
212 | by a dash (such as 'en-de.dic' for an English-German dictionary file).
|
206 | echo
|
213 | |
207 | echo "Program updates and dictionaries can be obtained from" |
214 | Program updates and dictionaries can be obtained from
|
208 | echo "'http://pointedears.de/dev/unix/translate/'." |
215 | 'http://pointedears.de/tools/eazytrans/'.
|
209 | echo "Thank you for using a program by PointedEars." |
216 | Thank you for using a program by PointedEars.
|
210 | echo
|
217 | "
|
211 | }
|
218 | }
|
212 | 219 | ||
213 | function devInfo { |
220 | devInfo() { |
214 | title |
221 | title |
215 | copyright |
222 | copyright |
216 | echo "INFORMATION FOR DEVELOPERS (KNOWN ISSUES)..." |
- | |
217 | echo
|
223 | echo "\ |
218 | echo "- Sorting the dictionary unfortunately also sorts its info data by now." |
- | |
219 | echo
|
224 | KNOWN ISSUES
|
220 | echo "...AND FOR EMPLOYERS:" |
- | |
221 | echo
|
225 | |
222 | echo "BTW, if you have an idea for improving EasyTranslator or for another (field of)" |
- | |
223 | echo "application you want me to develop for you (BASIC, DOS batch, Windows INF," |
226 | - Sorting the dictionary unfortunately also sorts its info data by now.
|
224 | echo "Visual Basic, bash, Pascal, Delphi, C, HTML/JavaScript, and I am still learning" |
- | |
225 | echo "other languages) feel free to mail me, too. THNX! -- PointedEars, 2001-03-28" |
- | |
226 | echo
|
227 | "
|
227 | }
|
228 | }
|
228 | 229 | ||
229 | function help { |
230 | help() { |
230 | copying |
231 | copying |
231 | if [ $SINGLE_PAGE -eq 0 ]; then pause ; fi |
232 | [ $single_page -eq 0 ] && pause |
232 | cmdHelp |
233 | cmdHelp |
233 | if [ $SINGLE_PAGE -eq 0 ]; then pause ; fi |
234 | [ $single_page -eq 0 ] && pause |
234 | example |
235 | example |
235 | if [ $SINGLE_PAGE -eq 0 ]; then pause ; fi |
236 | [ $single_page -eq 0 ] && pause |
236 | dictHelp |
237 | dictHelp |
237 | if [ $SINGLE_PAGE -eq 0 ]; then pause ; fi |
238 | [ $single_page -eq 0 ] && pause |
238 | devInfo |
239 | devInfo |
239 | }
|
240 | }
|
240 | 241 | ||
241 | function translateReverse { |
242 | check_dictionary() { |
242 | local EXPR="$1" |
243 | # check if dictionary file (contains at least '#$delimiter')
|
243 | if [ $VERBOSE -eq 1 ]; then echo "Executing: grep -i -e '"$DELIMITER$EXPR"$' '"$DICT"'" ; fi |
244 | [ $verbose -eq 1 ] && echo "Executing: grep -e '."$delimiter".' '"$dict"'" |
244 | RESULT=`grep -i -e "$DELIMITER$EXPR$" "$DICT"` |
245 | result=$(grep -e "#$delimiter." "$dict") |
- | 246 | if [ -z "$result" ]; then |
|
245 | if [ $VERBOSE -eq 1 ]; then echo "grep returned: '"$RESULT"'" ; fi |
247 | [ $verbose -eq 1 ] && echo "grep returned: ''" |
- | 248 | echo $dict": Not a (valid) dictionary file (type '"$appfilename" --d' for details)." |
|
246 | if [ -n "$RESULT" ]; then |
249 | [ $verbose -eq 1 ] && echo |
- | 250 | exit $EDICT_WRONG_FORMAT |
|
- | 251 | else
|
|
247 | if [ $VERBOSE -eq 1 ]; then |
252 | if [ $verbose -eq 1 ]; then |
248 | echo "Reading expression from recordset (with sed requires only 1 step! :o)" ; |
253 | echo "grep returned not a null-string: '$dict' seems to be a dictionary file" |
249 | echo "Executing: echo $RESULT | sed 's/$DELIMITER[ ]*[^$DELIMITER]*//'" |
- | |
250 | fi
|
254 | fi
|
251 | RESULT=`echo $RESULT | sed 's/'$DELIMITER'[ ]*[^'$DELIMITER']*//'` |
- | |
252 | if [ $VERBOSE -eq 1 ]; then echo "sed returned: '"$RESULT"'" ; fi |
- | |
253 | fi
|
255 | fi
|
254 | 256 | result="" |
|
255 | # Should return only characters before the delimiter until BOL (expression)
|
- | |
256 | }
|
257 | }
|
257 | 258 | ||
258 | function translate { |
259 | create() { |
259 | local EXPR="$1" |
- | |
260 | if [ $REVERSE -eq 1 ]; then translateReverse "$1" ; return ; fi |
- | |
261 | if [ $VERBOSE -eq 1 ]; then echo "Executing: grep -i -e '^"$EXPR$DELIMITER"' '"$DICT"'" ; fi |
- | |
262 | RESULT=`grep -i -e "^$EXPR$DELIMITER" "$DICT"` |
- | |
263 | if [ $VERBOSE -eq 1 ]; then echo "grep returned: '"$RESULT"'" ; fi |
260 | [ $verbose -eq 1 ] && echo $dict": Creating dictionary" |
264 | if [ -n "$RESULT" ]; then |
261 | if [ -z "$3" ]; then |
265 | if [ $VERBOSE -eq 1 ]; then |
- | |
266 | echo "Reading translation from recordset (with sed requires only 1 step! :o)" ; |
262 | [ $verbose -eq 1 ] && echo $dict": Adding information: '"$DEFAULT_INFO |
267 | echo "Executing: echo $RESULT | sed 's/[^$DELIMITER]*$DELIMITER[ ]*//'" |
263 | echo "#"$delimiter$DEFAULT_INFO &>$dict |
268 | fi
|
264 | else
|
269 | RESULT=`echo $RESULT | sed 's/[^'$DELIMITER']*'$DELIMITER'[ ]*//'` |
265 | [ $verbose -eq 1 ] && echo $dict": Adding information: '"$3"'" |
270 | if [ $VERBOSE -eq 1 ]; then echo "sed returned: '"$RESULT"'" ; fi |
266 | echo "#"$delimiter$3 &>$dict |
271 | fi
|
267 | fi
|
272 | - | ||
273 | # Should return only characters after the separation character until EOL
|
268 | [ $verbose -eq 1 ] && echo |
274 | # (translation)
|
269 | exit $? |
275 | }
|
270 | }
|
276 | 271 | ||
277 | # exit codes
|
272 | add_info() { |
278 | ESUCCESS=0 |
- | |
279 | ENO_DICT=1 |
- | |
280 | EDICT_DIR_NOT_FOUND=2 |
273 | if [ -z "$3" ]; then |
- | 274 | [ $verbose -eq 1 ] && echo $dict": Adding information: '"$DEFAULT_INFO"'" |
|
281 | EDICT_NOT_FOUND=3 |
275 | echo "#"$delimiter$DEFAULT_INFO >>$dict |
282 | EDICT_WRONG_FORMAT=4 |
276 | else
|
283 | EDICT_EXPR_CONTAINED=5 |
277 | [ $verbose -eq 1 ] && echo $dict": Adding information: '"$3"'" |
284 | EDICT_TEMP_ERROR=6 |
278 | echo "#"$delimiter$3 >>$dict |
285 | EDICT_CREATE_ERROR=7 |
279 | fi
|
286 | EDICT_DELETE_EXPR_NOT_FOUND=8 |
280 | [ $verbose -eq 1 ] && echo |
287 | EDICT_REMOVE=9 |
281 | exit $? |
288 | 282 | }
|
|
289 | # argument flags
|
- | |
290 | DICTIONARY=0 # if 1, -d refers to the dictionary file instead of an entry |
- | |
291 | 283 | ||
292 | # option flags - may be replaced by declare -i FLAG
|
- | |
293 | ADD=0 |
- | |
294 | ADDINFO=0 |
284 | info() { |
295 | BRACKETS=0 |
285 | if [ $verbose -eq 1 ]; then |
296 | CREATE=0 |
286 | echo "Obtaining information..." |
297 | DELETE=0 |
287 | echo
|
298 | INFO=0 |
288 | fi
|
- | 289 | grep "^#$delimiter" "$dict" | sed 's/^#'$delimiter'//' |
|
299 | MESSAGES=0 |
290 | result=$(grep -e "^#$delimiter" "$dict") |
- | 291 | [ -z "$result" ] && echo $ch_sound$dict": No information available" |
|
300 | OVERWRITE=0 |
292 | [ $verbose -eq 1 ] && echo |
301 | PHRASE=0 |
- | |
302 | REPAIR=0 |
- | |
303 | REVERSE=0 |
- | |
304 | SORT=0 |
- | |
305 | SOUND=0 |
- | |
306 | VERBOSE=0 |
293 | exit $ESUCCESS |
307 | ZERO=0 |
294 | }
|
308 | 295 | ||
309 | if [ -n "$1" ]; then |
- | |
310 | # retrieve arguments and use default settings from environment variable
|
- | |
311 | ARGUMENTS=$* ; if [ -n "$TRANSLATE_OPTIONS" ]; then ARGUMENTS=$ARGUMENTS" "$TRANSLATE_OPTIONS ; fi |
- | |
312 | # check options
|
296 | add_translation() { |
313 | for argument in $ARGUMENTS; do |
- | |
314 | case "$argument" in |
297 | [ $verbose -eq 1 ] && echo |
315 | "-b" | "--brackets") BRACKETS=1;; |
- | |
316 | "-m" | "--messages") MESSAGES=1;; |
- | |
317 | "-p" | "--phrase") PHRASE=1;; |
- | |
318 | "-r" | "--reverse") REVERSE=1;; |
- | |
319 | "-s" | "--sound") SOUND=1;; |
- | |
320 | "-v" | "--verbose") VERBOSE=1 ; title ; copyright;; |
298 | result=$(grep -i -e "^$1$delimiter" "$dict") |
321 | "-z" | "--zero") ZERO=1;; |
299 | if [ -z "$result" ]; then |
322 | "--a" | "--about") copying ; exit $ESUCCESS;; |
- | |
323 | "--c" | "--cmd") cmdHelp ; exit $ESUCCESS;; |
- | |
324 | "--d" | "--dict") dictHelp ; exit $ESUCCESS;; |
300 | echo $dict": Adding expression: '"$1"'" |
325 | "--dev" | "--emp") devInfo ; exit $ESUCCESS;; |
301 | echo $dict": Adding translation: '"$4"'" |
326 | "--1") SINGLE_PAGE=1;; |
302 | if [ -n "$4" ]; then |
327 | "--x" | "--example") example ; exit $ESUCCESS;; |
- | |
328 | "--?" | "--help") help ; exit $ESUCCESS;; |
303 | echo $1$delimiter$4 >>$dict |
329 | esac
|
304 | else
|
330 | done
|
- | |
331 | if [ $SOUND -eq 1 ]; then CH_SOUND=$CH_SOUND_ON ; fi |
305 | [ $messages -eq 1 ] || [ $verbose -eq 1 ] && echo $ch_sound$appfilename": No translation given for '"$1"'" |
332 | if [ -n "$2" ]; then |
- | |
333 | # concatenate dictionary root and given dictionary file
|
- | |
334 | DICT="$DICT$2" |
306 | fi
|
335 | # check for dictionary commands
|
- | |
336 | case "$1" in |
307 | sort=1 |
337 | "-d" | "--delete") DELETE=1 ; DICTIONARY=1 ;; |
- | |
338 | "-c" | "--create") CREATE=1;; |
- | |
339 | "-i" | "--info") INFO=1;; |
- | |
340 | "-s" | "--sort") SORT=1;; |
- | |
341 | "-R" | "--repair") REPAIR=1;; |
- | |
342 | esac
|
308 | else
|
343 | case "$3" in |
309 | translate "$1"
|
344 | "-a" | "--add") ADD=1;; |
- | |
345 | "-ai" | "--addinfo") ADDINFO=1;; |
310 | echo $ch_sound$dict": Expression already contained: '"$1"':"$result |
346 | "-d" | "--delete") DELETE=1;; |
311 | [ $verbose -eq 1 ] && echo |
347 | "-o" | "--overwrite") OVERWRITE=1;; |
312 | exit $EDICT_EXPR_CONTAINED |
348 | esac
|
313 | fi
|
- | 314 | }
|
|
349 | 315 | ||
- | 316 | replace_translation() { |
|
- | 317 | [ $verbose -eq 1 ] && echo |
|
- | 318 | echo $dict": Replacing expression: '"$1"'" |
|
- | 319 | echo $dict": Replacing translation: '"$4"'" |
|
- | 320 | TMPFILE=$(mktemp -q /tmp/$appfilename.XXXXXX) |
|
350 | if [ $VERBOSE -eq 1 ]; then |
321 | if [ $? -ne 0 ]; then |
- | 322 | [ $verbose -eq 1 ] && echo $appfilename": Can't create temp file, exiting..." |
|
- | 323 | exit EDICT_TEMP_ERROR
|
|
- | 324 | else
|
|
351 | if [ -z "$TRANSLATE_DIR" ]; then |
325 | if [ -n "$4" ]; then |
- | 326 | grep -iv -e "^$1$delimiter" "$dict" &>$TMPFILE |
|
352 | echo "Dictionary root (program directory): '"$APPFILEDIR"'" |
327 | [ $? -eq 0 ] && echo $1$delimiter$4 >>$TMPFILE |
- | 328 | [ $? -eq 0 ] && mv $TMPFILE $dict &>/dev/null |
|
- | 329 | if [ $? -ne 0 ]; then |
|
- | 330 | [ $verbose -eq 1 ] && echo $appfilename": Unable to replace dictionary file: '"$dict"'" |
|
- | 331 | exit EDICT_REPLACE_ERROR
|
|
353 | else
|
332 | else
|
354 | echo "Dictionary root (TRANSLATE_DIR): '"$TRANSLATE_DIR"'" |
333 | sort=1 |
355 | fi
|
334 | fi
|
356 | echo "Dictionary file: '"$2"'" |
335 | else
|
357 | echo "Dictionary file path: '"$DICT"'" |
336 | [ $messages -eq 1 ] || [ $verbose -eq 1 ] && echo $ch_sound$appfilename": No translation given for '"$1"'" |
358 | fi
|
337 | fi
|
- | 338 | fi
|
|
- | 339 | }
|
|
359 | 340 | ||
- | 341 | delete() { |
|
- | 342 | if [ $dictionary -eq 0 ]; then |
|
- | 343 | # delete entry
|
|
360 | DEFAULT_INFO=$APPNAME" "$APPVER" dictionary file created by '"`whoami`"' on "`date` |
344 | [ $verbose -eq 1 ] && echo $dict": Removing expression: "$1 |
361 | - | ||
- | 345 | result=$(grep -i -e "^$1$delimiter" "$dict") |
|
362 | if [ $CREATE -eq 1 ]; then |
346 | if [ -z "$result" ]; then |
- | 347 | [ $messages -eq 1 ] || [ $verbose -eq 1 ] && echo $dict": Expression not contained in dictionary: '"$1"'" |
|
- | 348 | exit $EDICT_DELETE_EXPR_NOT_FOUND |
|
- | 349 | fi
|
|
- | 350 | TMPFILE=$(mktemp -q /tmp/$appfilename.XXXXXX) |
|
363 | if [ $VERBOSE -eq 1 ]; then |
351 | if [ $? -ne 0 ]; then |
- | 352 | [ $verbose -eq 1 ] && echo $appfilename": Can't create temp file, exiting..." |
|
364 | echo $DICT": Creating dictionary" |
353 | exit EDICT_TEMP_ERROR
|
365 | fi
|
354 | else
|
- | 355 | grep -iv -e "$1$delimiter" "$dict" &>$TMPFILE |
|
- | 356 | [ $? -eq 0 ] && mv $TMPFILE $dict &>/dev/null |
|
366 | if [ -z "$3" ]; then |
357 | if [ $? -ne 0 ]; then |
367 | if [ $VERBOSE -eq 1 ]; then echo $DICT": Adding information: '"$DEFAULT_INFO ; fi |
358 | [ $verbose -eq 1 ] && echo $dict": Unable to modify dictionary (cannot replace file)" |
368 | echo "#"$DELIMITER$EFAULT_INFO &>$DICT |
359 | exit EDICT_REPLACE_ERROR
|
369 | else
|
360 | else
|
370 | if [ $VERBOSE -eq 1 ]; then echo $DICT": Adding information: '"$3"'" ; fi |
361 | [ $verbose -eq 1 ] && echo $dict": Modification successful" |
371 | echo "#"$DELIMITER$3 &>$DICT |
362 | exit $ESUCCESS |
372 | fi
|
363 | fi
|
373 | if [ $VERBOSE -eq 1 ]; then echo ; fi |
- | |
374 | exit $? |
- | |
375 | fi
|
364 | fi
|
376 | 365 | else
|
|
- | 366 | # delete dictionary
|
|
377 | if [ -e "$DICT" ]; then # if dictionary file exists |
367 | if [ $verbose -eq 1 ]; then |
378 | # check if dictionary file (contains at least '#$DELIMITER')
|
368 | echo $appfilename": Deleting dictionary: '"$dict"'" |
379 | if [ $VERBOSE -eq 1 ]; then echo "Executing: grep -e '."$DELIMITER".' '"$DICT"'" ; fi |
369 | echo $appfilename": Executing: rm '"$dict"' &>/dev/null" |
- | 370 | fi
|
|
380 | RESULT=`grep -e "#$DELIMITER." "$DICT"` |
371 | rm $dict &>/dev/null |
381 | if [ -z "$RESULT" ]; then |
372 | if [ $? -ne 0 ]; then |
382 | if [ $VERBOSE -eq 1 ]; then echo "grep returned: ''" ; fi |
373 | [ $messages -eq 1 ] || [ $verbose -eq 1 ] && echo $dict": Unable to remove dictionary" |
383 | echo $DICT": Not a (valid) dictionary file (type '"$APPFILENAME" --d' for details)." |
- | |
384 | if [ $VERBOSE -eq 1 ]; then echo ; fi |
- | |
385 | exit $EDICT_WRONG_FORMAT |
374 | exit $EDICT_REMOVE |
386 | else
|
375 | else
|
387 | if [ $VERBOSE -eq 1 ]; then |
376 | if [ $verbose -eq 1 ]; then |
388 | echo "grep returned not a null-string: '$DICT' seems to be a dictionary file" |
377 | echo $dict": Dictionary successfully removed" |
389 | fi
|
378 | echo
|
390 | fi
|
379 | fi
|
391 | RESULT="" |
380 | exit $ESUCCESS |
- | 381 | fi
|
|
- | 382 | fi
|
|
- | 383 | }
|
|
392 | 384 | ||
- | 385 | sort_dictionary() { |
|
393 | if [ $ADDINFO -eq 1 ]; then |
386 | if [ $verbose -eq 1 ]; then |
394 | if [ -z "$3" ]; then |
387 | echo "Sorting dictionary: '"$dict"'" |
395 | if [ $VERBOSE -eq 1 ]; then echo $DICT": Adding information: '"$DEFAULT_INFO"'" ; fi |
388 | echo "Executing: sort -d -f -o "$dict" -t "$delimiter" "$dict |
- | 389 | fi
|
|
396 | echo "#"$DELIMITER$DEFAULT_INFO >>$DICT |
390 | result=$(sort -d -f -o "$dict" -t $delimiter "$dict") |
397 | else
|
391 | SORT_EXIT=$? |
- | 392 | if [ $verbose -eq 1 ]; then |
|
398 | if [ $VERBOSE -eq 1 ]; then echo $DICT": Adding information: '"$3"'" ; fi |
393 | echo "sort returned exit code "$SORT_EXIT |
- | 394 | if [ $SORT_EXIT -eq 0 ]; then |
|
399 | echo "#"$DELIMITER$3 >>$DICT |
395 | echo "Sorting successful: '"$dict"'" |
400 | fi
|
396 | else
|
401 | if [ $VERBOSE -eq 1 ]; then echo ; fi |
397 | echo "Sorting failed: '"$dict"'" |
402 | exit $? |
398 | fi
|
403 | fi
|
399 | echo
|
- | 400 | fi
|
|
- | 401 | exit $SORT_EXIT |
|
- | 402 | }
|
|
404 | 403 | ||
- | 404 | repair() { |
|
405 | if [ $INFO -eq 1 ]; then |
405 | [ $verbose -eq 1 ] && echo $dict": Repairing dictionary" |
- | 406 | TMPFILE=$(mktemp -q /tmp/$appfilename.XXXXXX) |
|
406 | if [ $VERBOSE -eq 1 ]; then |
407 | if [ $? -ne 0 ]; then |
407 | echo "Obtaining information..." |
408 | [ $verbose -eq 1 ] && echo $appfilename": Can't create temp file, exiting..." |
408 | echo
|
409 | exit EDICT_TEMP_ERROR
|
409 | fi
|
410 | else
|
410 | grep "^#$DELIMITER" "$DICT" | sed 's/^#'$DELIMITER'//' |
411 | grep -e "^#$delimiter" "$dict" &>$TMPFILE |
411 | RESULT=`grep -e "^#$DELIMITER" "$DICT"` |
412 | grep -e ".$delimiter." "$dict" >>$TMPFILE |
412 | if [ -z "$RESULT" ]; then echo $CH_SOUND$DICT": No information available" ; fi |
413 | [ $? -eq 0 ] && mv $TMPFILE $dict &>/dev/null |
413 | if [ $VERBOSE -eq 1 ]; then echo ; fi |
414 | if [ $? -ne 0 ]; then |
- | 415 | [ $verbose -eq 1 ] && echo $dict": Unable to repair dictionary (cannot replace file)" |
|
414 | exit $ESUCCESS |
416 | exit EDICT_REPLACE_ERROR
|
- | 417 | else
|
|
- | 418 | $dict": Repair successful" |
|
415 | fi
|
419 | fi
|
- | 420 | fi
|
|
- | 421 | }
|
|
416 | 422 | ||
- | 423 | translateReverse() { |
|
417 | if [ $ADD -eq 1 ]; then |
424 | local EXPR="$1" |
418 | if [ $VERBOSE -eq 1 ]; then echo ; fi |
425 | [ $verbose -eq 1 ] && echo >&2 "Executing: grep -i -e '"$delimiter$EXPR"$' '"$dict"'" |
- | 426 | result=$(egrep -i -e "$delimiter(\([^\)]+\))?.*\<$EXPR\>.*(\([^\)]+\))?$" "$dict") |
|
419 | RESULT=`grep -i -e "^$1$DELIMITER" "$DICT"` |
427 | [ $verbose -eq 1 ] && echo >&2 "grep returned: '"$result"'" |
420 | if [ -z "$RESULT" ]; then |
428 | if [ -n "$result" ]; then |
- | 429 | if [ $verbose -eq 1 ]; then |
|
- | 430 | echo >&2 "Reading expression from recordset (with sed requires only 1 step! :o) |
|
421 | echo $DICT": Adding expression: '"$1"'" |
431 | Executing: echo $result | sed 's/$delimiter[ ]*[^$delimiter]*//'"
|
- | 432 | fi
|
|
422 | echo $DICT": Adding translation: '"$4"'" |
433 | # result=$(echo $result | sed 's/'$delimiter'[ ]*[^'$delimiter']*//')
|
423 | if [ -n "$4" ]; then |
434 | result=$(echo $result | sed 's/'$delimiter'.*$//') |
424 | echo $1$DELIMITER$4 >>$DICT |
435 | [ $verbose -eq 1 ] && echo >&2 "sed returned: '"$result"'" |
425 | else
|
436 | fi
|
- | 437 | ||
426 | if [ $MESSAGES -eq 1 ] || [ $VERBOSE -eq 1 ]; then echo $CH_SOUND$APPFILENAME": No translation given for '"$1"'" ; fi |
438 | # Should return only characters before the delimiter until BOL (expression)
|
- | 439 | }
|
|
- | 440 | ||
427 | fi
|
441 | translate() { |
428 | SORT=1 |
442 | local EXPR="$1" |
429 | else
|
443 | if [ $reverse -eq 1 ]; then |
430 | translate "$1"
|
444 | translateReverse "$1"
|
- | 445 | return
|
|
- | 446 | fi
|
|
- | 447 | [ $verbose -eq 1 ] && echo >&2 "Executing: grep -i -e '^"$EXPR$delimiter"' '"$dict"'" |
|
- | 448 | result=$(grep -i -e "^$EXPR$delimiter" "$dict") |
|
431 | echo $CH_SOUND$DICT": Expression already contained: '"$1"':"$RESULT |
449 | [ $verbose -eq 1 ] && echo >&2 "grep returned: '"$result"'" |
- | 450 | if [ -n "$result" ]; then |
|
432 | if [ $VERBOSE -eq 1 ]; then echo ; fi |
451 | if [ $verbose -eq 1 ]; then |
- | 452 | echo >&2 "Reading translation from recordset (with sed requires only 1 step! :o) |
|
433 | exit $EDICT_EXPR_CONTAINED |
453 | Executing: echo $result | sed 's/[^$delimiter]*$delimiter[ ]*//'"
|
434 | fi
|
454 | fi
|
- | 455 | result=$(echo $result | sed 's/[^'$delimiter']*'$delimiter'[ ]*//') |
|
- | 456 | [ $verbose -eq 1 ] && echo >&2 "sed returned: '"$result"'" |
|
435 | fi
|
457 | fi
|
- | 458 | ||
- | 459 | # Should return only characters after the separation character until EOL
|
|
- | 460 | # (translation)
|
|
- | 461 | }
|
|
436 | 462 | ||
- | 463 | translate_all() { |
|
- | 464 | local second_pass=0 |
|
- | 465 | [ "$1" = "-2" ] && { |
|
- | 466 | shift
|
|
- | 467 | second_pass=1 |
|
- | 468 | }
|
|
- | 469 | TRANSL="" |
|
- | 470 | REVERSE_TRANSL="" |
|
- | 471 | REVERSE_TRANSL_CAPT="T" |
|
- | 472 | REVERSE_TRANSL_on=" (reverse)" |
|
- | 473 | REVERSE_TRANSL_CAPT_on="Reverse t" |
|
437 | if [ $OVERWRITE -eq 1 ]; then |
474 | if [ $reverse -eq 1 ]; then |
- | 475 | REVERSE_TRANSL=$REVERSE_TRANSL_on |
|
- | 476 | REVERSE_TRANSL_CAPT=$REVERSE_TRANSL_CAPT_on |
|
- | 477 | fi
|
|
438 | if [ $VERBOSE -eq 1 ]; then echo ; fi |
478 | if [ $phrase -eq 1 ] ; then |
439 | echo $DICT": Replacing expression: '"$1"'" |
479 | [ $verbose -eq 1 ] && echo "Looking up phrase"$REVERSE_TRANSL": '"$1"'" |
440 | echo $DICT": Replacing translation: '"$4"'" |
480 | if [ $zero -eq 0 ]; then |
- | 481 | TRANSL="$1" |
|
441 | TMPFILE=`mktemp -q /tmp/$APPFILENAME.XXXXXX` |
482 | [ $brackets -eq 1 ] && TRANSL="["$TRANSL"]" |
- | 483 | fi
|
|
- | 484 | translate "$1"
|
|
442 | if [ $? -ne 0 ]; then |
485 | if [ -n "$result" ]; then |
- | 486 | TRANSL=$result |
|
443 | if [ $VERBOSE -eq 1 ]; then echo $APPFILENAME": Can't create temp file, exiting..." ; fi |
487 | [ $verbose -eq 1 ] && echo $REVERSE_TRANSL_CAPT"ranslation: '"$TRANSL"'" |
- | 488 | else
|
|
- | 489 | if [ $verbose -eq 1 ]; then |
|
444 | exit EDICT_TEMP_ERROR
|
490 | if [ $zero -eq 1 ]; then |
- | 491 | echo $REVERSE_TRANSL_CAPT"ranslation failed (return not translatable tokens as null-string): '"$1"'" |
|
445 | else
|
492 | else
|
446 | if [ -n "$4" ]; then |
- | |
447 | grep -iv -e "^$1$DELIMITER" "$DICT" &>$TMPFILE |
- | |
448 | if [ $? -eq 0 ]; then echo $1$DELIMITER$4 >>$TMPFILE ; fi |
- | |
449 | if [ $? -eq 0 ]; then mv $TMPFILE $DICT &>/dev/null ; fi |
- | |
450 | if [ $? -ne 0 ]; then |
493 | if [ $brackets -eq 1 ]; then |
451 | if [ $VERBOSE -eq 1 ]; then echo $APPFILENAME": Unable to replace dictionary file: '"$DICT"'" ; fi |
494 | echo $ch_sound$REVERSE_TRANSL_CAPT"ranslation failed (enclosing phrase in brackets): '"$1"'" |
452 | exit EDICT_REPLACE_ERROR
|
- | |
453 | else
|
- | |
454 | SORT=1 |
- | |
455 | fi
|
- | |
456 | else
|
495 | else
|
457 | if [ $MESSAGES -eq 1 ] || [ $VERBOSE -eq 1 ]; then echo $CH_SOUND$APPFILENAME": No translation given for '"$1"'" ; fi |
496 | echo $ch_sound$REVERSE_TRANSL_CAPT"ranslation failed (leave 'as is'): '"$1"'" |
458 | fi
|
497 | fi
|
459 | fi
|
498 | fi
|
460 | fi
|
499 | fi
|
- | 500 | fi
|
|
461 | 501 | else
|
|
- | 502 | for word in $@; do |
|
462 | if [ $DELETE -eq 1 ]; then |
503 | if [ $zero -eq 0 ]; then |
463 | if [ $DICTIONARY -eq 0 ]; then |
504 | TRANSLWORD="$word" |
- | 505 | else
|
|
464 | # delete entry
|
506 | TRANSLWORD="" |
- | 507 | fi
|
|
465 | if [ $VERBOSE -eq 1 ]; then echo $DICT": Removing expression: "$1 ; fi |
508 | [ $verbose -eq 1 ] && echo "Looking up word"$REVERSE_TRANSL": "$word |
466 | RESULT=`grep -i -e "^$1$DELIMITER" "$DICT"` |
509 | translate "$word"
|
467 | if [ -z "$RESULT" ]; then |
510 | if [ -n "$result" ]; then |
- | 511 | TRANSLWORD=$result |
|
468 | if [ $MESSAGES -eq 1 ] || [ $VERBOSE -eq 1 ]; then echo $DICT": Expression not contained in dictionary: '"$1"'" ; fi |
512 | elif [ -n "$wsep" ] && [ $second_pass -eq 0 ]; then |
- | 513 | word=${word//$wsep/ } |
|
- | 514 | translate_all -2 $word |
|
469 | exit $EDICT_DELETE_EXPR_NOT_FOUND |
515 | if [ -n "$result" ]; then |
- | 516 | TRANSLWORD=$result |
|
470 | fi
|
517 | fi
|
- | 518 | fi
|
|
471 | TMPFILE=`mktemp -q /tmp/$APPFILENAME.XXXXXX` |
519 | [ -n "$result" ] && [ $verbose -eq 1 ] && echo $REVERSE_TRANSL_CAPT"ranslation: '"$TRANSLWORD"'" |
- | 520 | ||
472 | if [ $? -ne 0 ]; then |
521 | if [ -z "$result" ]; then |
473 | if [ $VERBOSE -eq 1 ]; then echo $APPFILENAME": Can't create temp file, exiting..." ; fi |
522 | [ $zero -eq 0 ] && [ $brackets -eq 1 ] && TRANSLWORD="["$TRANSLWORD"]" |
- | 523 | if [ $verbose -eq 1 ]; then |
|
474 | exit EDICT_TEMP_ERROR
|
524 | if [ $zero -eq 1 ]; then |
- | 525 | echo $REVERSE_TRANSL_CAPT"ranslation failed (return not translatable tokens as null-string): "$word |
|
475 | else
|
526 | else
|
476 | grep -iv -e "$1$DELIMITER" "$DICT" &>$TMPFILE |
- | |
477 | if [ $? -eq 0 ]; then mv $TMPFILE $DICT &>/dev/null ; fi |
- | |
478 | if [ $? -ne 0 ]; then |
527 | if [ $brackets -eq 1 ]; then |
479 | if [ $VERBOSE -eq 1 ]; then echo $DICT": Unable to modify dictionary (cannot replace file)" ; fi |
528 | echo $REVERSE_TRANSL_CAPT"ranslation failed (enclosing word in brackets): "$word |
480 | exit EDICT_REPLACE_ERROR
|
- | |
481 | else
|
529 | else
|
482 | if [ $VERBOSE -eq 1 ]; then echo $DICT": Modification successful" ; fi |
530 | echo $REVERSE_TRANSL_CAPT"ranslation failed (leave 'as is'): "$word |
483 | exit $ESUCCESS |
- | |
484 | fi
|
531 | fi
|
485 | fi
|
532 | fi
|
486 | else
|
- | |
487 | # delete dictionary
|
- | |
488 | if [ $VERBOSE -eq 1 ]; then |
- | |
489 | echo $APPFILENAME": Deleting dictionary: '"$DICT"'" |
- | |
490 | echo $APPFILENAME": Executing: rm '"$DICT"' &>/dev/null" |
- | |
491 | fi
|
- | |
492 | rm $DICT &>/dev/null |
- | |
493 | if [ $? -ne 0 ]; then |
- | |
494 | if [ $MESSAGES -eq 1 ] || [ $VERBOSE -eq 1 ]; then echo $DICT": Unable to remove dictionary" ; fi |
- | |
495 | exit $EDICT_REMOVE |
- | |
496 | else
|
- | |
497 | if [ $VERBOSE -eq 1 ]; then |
- | |
498 | echo $DICT": Dictionary successfully removed" |
- | |
499 | echo
|
- | |
500 | fi
|
- | |
501 | exit $ESUCCESS |
- | |
502 | fi
|
- | |
503 | fi
|
533 | fi
|
504 | fi
|
534 | fi
|
- | 535 | TRANSL=$TRANSL" "$TRANSLWORD |
|
- | 536 | done
|
|
- | 537 | fi
|
|
- | 538 | }
|
|
505 | 539 | ||
506 | if [ $SORT -eq 1 ]; then |
540 | # exit codes
|
507 | if [ $VERBOSE -eq 1 ]; then |
- | |
508 | echo "Sorting vocabulary: '"$DICT"'" |
- | |
509 | echo "Executing: sort -d -f -o "$DICT" -t "$DELIMITER" "$DICT |
- | |
510 | fi
|
541 | ESUCCESS=0 |
511 | RESULT=`sort -d -f -o "$DICT" -t $DELIMITER "$DICT"` |
- | |
512 | SORT_EXIT=$? |
542 | ENO_DICT=1 |
513 | if [ $VERBOSE -eq 1 ]; then |
- | |
514 | echo "sort returned exit code "$SORT_EXIT |
- | |
515 | if [ $SORT_EXIT -eq 0 ]; then |
543 | EDICT_DIR_NOT_FOUND=2 |
516 | echo "Sorting successful: '"$DICT"'" |
- | |
517 | else
|
544 | EDICT_NOT_FOUND=3 |
518 | echo "Sorting failed: '"$DICT"'" |
545 | EDICT_WRONG_FORMAT=4 |
519 | fi
|
546 | EDICT_EXPR_CONTAINED=5 |
520 | echo
|
547 | EDICT_TEMP_ERROR=6 |
521 | fi
|
548 | EDICT_CREATE_ERROR=7 |
522 | exit $SORT_EXIT |
549 | EDICT_DELETE_EXPR_NOT_FOUND=8 |
523 | fi
|
550 | EDICT_REMOVE=9 |
524 | 551 | ||
525 | if [ $REPAIR -eq 1 ]; then |
- | |
526 | if [ $VERBOSE -eq 1 ]; then echo $DICT": Repairing dictionary" ; fi |
- | |
527 | TMPFILE=`mktemp -q /tmp/$APPFILENAME.XXXXXX` |
- | |
528 | if [ $? -ne 0 ]; then |
- | |
529 | if [ $VERBOSE -eq 1 ]; then echo $APPFILENAME": Can't create temp file, exiting..." ; fi |
- | |
530 | exit EDICT_TEMP_ERROR
|
- | |
531 | else
|
552 | # argument flags
|
532 | grep -e "^#$DELIMITER" "$DICT" &>$TMPFILE |
- | |
533 | grep -e ".$DELIMITER." "$DICT" >>$TMPFILE |
- | |
534 | if [ $? -eq 0 ]; then mv $TMPFILE $DICT &>/dev/null ; fi |
553 | dictionary=0 # if 1, -d refers to the dictionary file instead of an entry |
535 | if [ $? -ne 0 ]; then |
- | |
536 | if [ $VERBOSE -eq 1 ]; then echo $DICT": Unable to repair dictionary (cannot replace file)" ; fi |
- | |
537 | exit EDICT_REPLACE_ERROR
|
- | |
538 | else
|
- | |
539 | $DICT": Repair successful" |
- | |
540 | fi
|
- | |
541 | fi
|
- | |
542 | fi
|
- | |
543 | 554 | ||
- | 555 | # option flags - may be replaced by declare -i FLAG
|
|
- | 556 | add=0 |
|
- | 557 | addinfo=0 |
|
- | 558 | brackets=0 |
|
- | 559 | create=0 |
|
- | 560 | delete=0 |
|
- | 561 | info=0 |
|
- | 562 | messages=0 |
|
- | 563 | overwrite=0 |
|
- | 564 | phrase=0 |
|
- | 565 | repair=0 |
|
- | 566 | reverse=0 |
|
544 | TRANSL="" |
567 | show_version=0 |
- | 568 | sort=0 |
|
- | 569 | sound=0 |
|
- | 570 | verbose=0 |
|
- | 571 | zero=0 |
|
- | 572 | ||
- | 573 | if $(getopt -T >/dev/null 2>&1); [ $? = 4 ]; then |
|
545 | REVERSE_TRANSL="" |
574 | getopt_type=long
|
546 | REVERSE_TRANSL_CAPT="T" |
575 | # echo "getopt(1) type: enhanced" >&2
|
- | 576 | tmp=$(getopt -o hVbmpoRrSsvzA:a:c:D:d:E:e:i:t: \ |
|
547 | REVERSE_TRANSL_ON=" (reverse)" |
577 | -l help,version\ |
- | 578 | ,brackets,messages,phrase,overwrite,repair,reverse,sort,sound,verbose,zero\
|
|
- | 579 | ,add:,addinfo:,dictionary:,delete:word-separator:\ |
|
- | 580 | ,about,cmd,dictionary-help,dev,emp,1,x,example \
|
|
548 | REVERSE_TRANSL_CAPT_ON="Reverse t" |
581 | -n "$appname" \ |
549 | if [ $REVERSE -eq 1 ]; then |
582 | -- "$@") |
- | 583 | else
|
|
- | 584 | getopt_type=short
|
|
550 | REVERSE_TRANSL=$REVERSE_TRANSL_ON |
585 | # echo "getopt(1) type: old" >&2
|
551 | REVERSE_TRANSL_CAPT=$REVERSE_TRANSL_CAPT_ON |
586 | tmp=$(getopt bdhVmpoRrSsvzA:a:c:D:E:e:i: "$@") |
552 | fi
|
587 | fi
|
- | 588 | ||
- | 589 | getopt_exit_code=$? |
|
- | 590 | ||
553 | if [ $PHRASE -eq 1 ] ; then |
591 | if [ $getopt_exit_code -eq 0 ]; then |
554 | if [ $VERBOSE -eq 1 ]; then echo "Looking up phrase"$REVERSE_TRANSL": '"$1"'" ; fi |
592 | ## getopt returns error code 0 for successful parsing, 1 if
|
- | 593 | ## getopt(3) returns errors, 2 if it does not understand its
|
|
- | 594 | ## own parameters, 3 if an internal error occurs like out-of-
|
|
555 | if [ $ZERO -eq 0 ]; then |
595 | ## memory, and 4 if it is called with -T.
|
- | 596 | #
|
|
- | 597 | # Note the quotes around '$tmp': they are essential!
|
|
- | 598 | # echo $tmp
|
|
- | 599 | # remove "--"
|
|
556 | TRANSL="$1" ; if [ $BRACKETS -eq 1 ]; then TRANSL="["$TRANSL"]" ; fi |
600 | # for i in $tmp; do if [ "$i" != "--" ]; then tmp2="${tmp2} $i"; fi; done
|
- | 601 | eval set -- "$tmp" |
|
- | 602 | echo "${extd}New arguments: $*$norm" >&2 |
|
- | 603 | ||
- | 604 | # First pass to make sure that only help is displayed if wanted
|
|
557 | fi
|
605 | for arg in $* |
- | 606 | do
|
|
558 | translate "$1"
|
607 | case "$arg" in |
- | 608 | -h | --help) help; exit $ESUCCESS;; |
|
559 | if [ -n "$RESULT" ]; then |
609 | # -V | --version) show_version=1;;
|
560 | TRANSL=$RESULT |
610 | --) break;; |
- | 611 | esac
|
|
- | 612 | done
|
|
- | 613 | ||
561 | if [ $VERBOSE -eq 1 ]; then echo $REVERSE_TRANSL_CAPT"ranslation: '"$TRANSL"'" ; fi |
614 | # Second pass to deal with the other options
|
- | 615 | while true |
|
- | 616 | do
|
|
- | 617 | case "$1" in |
|
562 | else
|
618 | # switches
|
563 | if [ $VERBOSE -eq 1 ]; then |
619 | -b | --brackets) brackets=1;; |
564 | if [ $ZERO -eq 1 ]; then |
620 | -r | --reverse) reverse=1;; |
565 | echo $REVERSE_TRANSL_CAPT"ranslation failed (return not translatable tokens as null-string): '"$1"'" |
621 | -v | --verbose) verbose=1; title; copyright;; |
566 | else
|
622 | # options
|
567 | if [ $BRACKETS -eq 1 ]; then |
623 | -D | --dictionary) shift; dict="$1";; |
568 | echo $CH_SOUND$REVERSE_TRANSL_CAPT"ranslation failed (enclosing phrase in brackets): '"$1"'" |
624 | -t | --word-separator) shift; wsep="$1";; |
569 | else
|
625 | --) shift; break;; |
- | 626 | esac
|
|
- | 627 | shift
|
|
- | 628 | done
|
|
- | 629 | [ -n "$*" ] && args=$args" $*" |
|
570 | echo $CH_SOUND$REVERSE_TRANSL_CAPT"ranslation failed (leave 'as is'): '"$1"'" |
630 | [ -z "$args" -a $show_version -eq 0 -a -z "$dict" ] && echo help |
571 | fi
|
631 | set -- $args |
- | 632 | else
|
|
- | 633 | # echo "getopt exited: $getopt_exit_code
|
|
572 | fi
|
634 | # " >&2
|
- | 635 | if [ $getopt_exit_code -eq 1 ] || [ $getopt_exit_code -eq 2 ]; then |
|
573 | fi
|
636 | echo
|
574 | fi
|
637 | echo help |
575 | else
|
638 | else
|
576 | for word in $1; do |
639 | exit $getopt_exit_code |
- | 640 | fi
|
|
- | 641 | fi
|
|
- | 642 | ||
- | 643 | if [ -n "$1" ]; then |
|
577 | if [ $ZERO -eq 0 ]; then TRANSLWORD="$word" ; else TRANSLWORD="" ; fi |
644 | # retrieve arguments and use default settings from environment variable
|
- | 645 | arguments=$* |
|
578 | if [ $VERBOSE -eq 1 ]; then echo "Looking up word"$REVERSE_TRANSL": "$word ; fi |
646 | [ -n "$TRANSLATE_OPTIONS" ] && arguments=$arguments" "$TRANSLATE_OPTIONS |
- | 647 | ||
- | 648 | # check options
|
|
- | 649 | # for argument in $arguments
|
|
- | 650 | # do
|
|
579 | translate "$word"
|
651 | # case "$argument" in
|
- | 652 | # "-m" | "--messages") messages=1;;
|
|
580 | if [ -n "$RESULT" ]; then |
653 | # "-p" | "--phrase") phrase=1;;
|
- | 654 | # "-r" | "--reverse") reverse=1;;
|
|
- | 655 | # "-s" | "--sound") sound=1;;
|
|
581 | TRANSLWORD=$RESULT |
656 | # "-z" | "--zero") zero=1;;
|
- | 657 | # "--a" | "--about") copying; exit $ESUCCESS;;
|
|
- | 658 | # "--c" | "--cmd") cmdHelp; exit $ESUCCESS;;
|
|
582 | if [ -n "$RESULT" ] && [ $VERBOSE -eq 1 ]; then echo $REVERSE_TRANSL_CAPT"ranslation: '"$TRANSLWORD"'" ; fi |
659 | # "--d" | "--dictionary-help") dictHelp; exit $ESUCCESS;;
|
- | 660 | # "--dev" | "--emp") devInfo; exit $ESUCCESS;;
|
|
583 | else
|
661 | # "--1") single_page=1;;
|
584 | if [ $ZERO -eq 0 ] && [ $BRACKETS -eq 1 ]; then TRANSLWORD="["$TRANSLWORD"]" ; fi |
662 | # "--x" | "--example") example; exit $ESUCCESS;;
|
585 | if [ $VERBOSE -eq 1 ]; then |
663 | # "-h" | "--help") help; exit $ESUCCESS;;
|
- | 664 | # esac
|
|
- | 665 | # done
|
|
- | 666 | ||
- | 667 | [ $sound -eq 1 ] && ch_sound=$ch_sound_on |
|
- | 668 | ||
586 | if [ $ZERO -eq 1 ]; then |
669 | if [ -n "$dict" ]; then |
587 | echo $REVERSE_TRANSL_CAPT"ranslation failed (return not translatable tokens as null-string): "$word |
670 | # # concatenate dictionary root and given dictionary file
|
588 | else
|
671 | # dict="$dict$2"
|
589 | if [ $BRACKETS -eq 1 ]; then |
672 | # # check for dictionary commands
|
- | 673 | # case "$1" in
|
|
590 | echo $REVERSE_TRANSL_CAPT"ranslation failed (enclosing word in brackets): "$word |
674 | # "-d" | "--delete") delete=1 ; dictionary=1 ;;
|
591 | else
|
675 | # "-c" | "--create") create1;;
|
592 | echo $REVERSE_TRANSL_CAPT"ranslation failed (leave 'as is'): "$word |
676 | # "-i" | "--info") info=1;;
|
593 | fi
|
677 | # "-S" | "--sort") sort=1;;
|
- | 678 | # "-R" | "--repair") repair=1;;
|
|
594 | fi
|
679 | # esac
|
- | 680 | #
|
|
595 | fi
|
681 | # case "$3" in
|
- | 682 | # "-a" | "--add") add=1;;
|
|
- | 683 | # "-A" | "--addinfo") addinfo=1;;
|
|
- | 684 | # "-d" | "--delete") delete=1;;
|
|
- | 685 | # "-o" | "--overwrite") overwrite=1;;
|
|
596 | fi
|
686 | # esac
|
- | 687 | #
|
|
- | 688 | # if [ $verbose -eq 1 ]; then
|
|
597 | TRANSL=$TRANSL" "$TRANSLWORD |
689 | # if [ -z "$TRANSLATE_DIR" ]; then
|
- | 690 | # echo "Dictionary root (program directory): '"$appfiledir"'"
|
|
598 | done
|
691 | # else
|
- | 692 | # echo "Dictionary root (TRANSLATE_DIR): '"$TRANSLATE_DIR"'"
|
|
599 | fi
|
693 | # fi
|
- | 694 | # echo "Dictionary file: '$2'"
|
|
- | 695 | # echo "Dictionary file path: '$dict'"
|
|
- | 696 | # fi
|
|
- | 697 | #
|
|
- | 698 | # DEFAULT_INFO="$appname $appver dictionary file created by '$(whoami)' on $(date)"
|
|
- | 699 | #
|
|
- | 700 | # [ $create -eq 1 ] && create
|
|
- | 701 | #
|
|
- | 702 | if [ -e "$dict" ]; then # if dictionary file exists |
|
- | 703 | check_dictionary |
|
- | 704 | ||
- | 705 | # [ $addinfo -eq 1 ] && add_info
|
|
- | 706 | # [ $info -eq 1 ] && info
|
|
- | 707 | # [ $add -eq 1 ] && add_translation
|
|
- | 708 | # [ $overwrite -eq 1 ] && replace_translation
|
|
- | 709 | # [ $delete -eq 1 ] && delete
|
|
- | 710 | # [ $sort -eq 1 ] && sort_dictionary
|
|
- | 711 | # [ $repair -eq 1 ] && repair
|
|
- | 712 | ||
- | 713 | translate_all "$@"
|
|
- | 714 | ||
600 | if [ $VERBOSE -eq 1 ]; then echo "Overall translation:" ; fi |
715 | [ $verbose -eq 1 ] && echo "Overall translation:" |
601 | if [ -n "$TRANSL" ]; then echo $TRANSL ; fi |
716 | [ -n "$TRANSL" ] && echo $TRANSL |
602 | if [ $VERBOSE -eq 1 ]; then echo ; fi |
717 | [ $verbose -eq 1 ] && echo |
603 | else
|
718 | else
|
604 | # send errmsg to stderr
|
719 | # send errmsg to stderr
|
605 | if [ -n "$TRANSLATE_DIR" ] && [ ! -e "$TRANSLATE_DIR" ]; then |
720 | if [ -n "$TRANSLATE_DIR" ] && [ ! -e "$TRANSLATE_DIR" ]; then |
606 | if [ $MESSAGES -eq 1 ] || [ $VERBOSE -eq 1 ]; then echo $CH_SOUND"$APPFILENAME: Unable to locate dictionary root: '"$TRANSLATE_DIR"'" 1>&2 ; fi |
721 | [ $messages -eq 1 ] || [ $verbose -eq 1 ] && echo $ch_sound"$appfilename: Unable to locate dictionary root: '"$TRANSLATE_DIR"'" 1>&2 |
607 | else
|
722 | else
|
608 | if [ $INFO -eq 0 ] && [ $ADD -eq 1 ] || [ $OVERWRITE -eq 1 ]; then |
723 | if [ $info -eq 0 ] && [ $add -eq 1 ] || [ $overwrite -eq 1 ]; then |
609 | if [ $VERBOSE -eq 1 ]; then |
724 | if [ $verbose -eq 1 ]; then |
610 | echo
|
725 | echo
|
611 | echo $DICT": Creating dictionary" |
726 | echo $dict": Creating dictionary" |
612 | fi
|
727 | fi
|
613 | if [ -n "$4" ]; then |
728 | if [ -n "$4" ]; then |
614 | if [ -z "$5" ]; then |
729 | if [ -z "$5" ]; then |
615 | if [ $VERBOSE -eq 1 ]; then echo $DICT": Adding information: '"$APPNAME" "$APPVER" dictionary file created by '"`whoami`"' on "`date`"'" ; fi |
730 | [ $verbose -eq 1 ] && echo $dict": Adding information: '"$appname" "$appver" dictionary file created by '"$(whoami)"' on "$(date)"'" |
616 | echo "#"$DELIMITER$APPNAME" "$APPVER" dictionary file created by '"`whoami`"' on "`date` &>$DICT |
731 | echo "#"$delimiter$appname" "$appver" dictionary file created by '"$(whoami)"' on "$(date) &>$dict |
617 | else
|
732 | else
|
618 | if [ $VERBOSE -eq 1 ]; then echo $DICT": Adding information: '"$5"'" ; fi |
733 | [ $verbose -eq 1 ] && echo $dict": Adding information: '"$5"'" |
619 | echo "#"$DELIMITER$5 &>$DICT |
734 | echo "#"$delimiter$5 &>$dict |
620 | fi
|
735 | fi
|
621 | if [ $? -eq 0 ]; then |
736 | if [ $? -eq 0 ]; then |
622 | if [ $VERBOSE -eq 1 ]; then |
737 | if [ $verbose -eq 1 ]; then |
623 | echo $DICT": Adding expression: '"$1"'" |
738 | echo $dict": Adding expression: '"$1"'" |
624 | echo $DICT": Adding translation: '"$4"'" |
739 | echo $dict": Adding translation: '"$4"'" |
625 | fi
|
740 | fi
|
626 | echo $1$DELIMITER$4 >>$DICT |
741 | echo $1$delimiter$4 >>$dict |
627 | else
|
742 | else
|
628 | if [ $MESSAGES -eq 1 ] || [ $VERBOSE -eq 1 ]; then echo $CH_SOUND$APPFILENAME": Unable to create dictionary file: '"$DICT"'" ; fi |
743 | [ $messages -eq 1 ] || [ $verbose -eq 1 ] && echo $ch_sound$appfilename": Unable to create dictionary file: '"$dict"'" |
629 | exit EDICT_CREATE_ERROR
|
744 | exit EDICT_CREATE_ERROR
|
630 | fi
|
745 | fi
|
631 | else
|
746 | else
|
632 | if [ $MESSAGES -eq 1 ] || [ $VERBOSE -eq 1 ]; then echo $CH_SOUND$APPFILENAME": No translation given for '"$1"'" ; fi |
747 | [ $messages -eq 1 ] || [ $verbose -eq 1 ] && echo $ch_sound$appfilename": No translation given for '"$1"'" |
633 | fi
|
748 | fi
|
634 | else
|
749 | else
|
- | 750 | if [ $messages -eq 1 ] || [ $verbose -eq 1 ]; then |
|
635 | if [ $MESSAGES -eq 1 ] || [ $VERBOSE -eq 1 ]; then echo $CH_SOUND$APPFILENAME": Unable to locate dictionary file: '"$DICT"' (please double-quote phrases)" 1>&2 ; fi |
751 | echo >&2 "$ch_sound$appfilename: Unable to locate dictionary file: '$dict'" |
- | 752 | fi
|
|
636 | fi
|
753 | fi
|
637 | fi
|
754 | fi
|
638 | if [ $VERBOSE -eq 1 ]; then echo ; fi |
755 | [ $verbose -eq 1 ] && echo |
639 | if [ -n "$TRANSLATE_DIR" ] && [ ! -e "$TRANSLATE_DIR" ]; then |
756 | if [ -n "$TRANSLATE_DIR" ] && [ ! -e "$TRANSLATE_DIR" ]; then |
640 | exit $EDICT_DIR_NOT_FOUND |
757 | exit $EDICT_DIR_NOT_FOUND |
641 | else
|
758 | else
|
642 | exit $EDICT_NOT_FOUND |
759 | exit $EDICT_NOT_FOUND |
643 | fi
|
760 | fi
|
644 | fi
|
761 | fi
|
645 | else
|
762 | else
|
646 | if [ $MESSAGES -eq 1 ] || [ $VERBOSE -eq 1 ]; then |
763 | if [ $messages -eq 1 ] || [ $verbose -eq 1 ]; then |
647 | # send errmsg to stderr
|
764 | # send errmsg to stderr
|
648 | echo $CH_SOUND$APPFILENAME": No dictionary file given" 1>&2 |
765 | echo >&2 $ch_sound$appfilename": No dictionary file given" |
649 | fi
|
766 | fi
|
650 | if [ $VERBOSE -eq 1 ]; then echo ; fi |
767 | [ $verbose -eq 1 ] && echo |
651 | exit $ENO_DICT |
768 | exit $ENO_DICT |
652 | fi
|
769 | fi
|
653 | else
|
770 | else
|
654 | help
|
771 | help
|
655 | fi
|
772 | fi
|