/usr/lib/surfraw/translate is in surfraw 2.2.8-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | #!/bin/sh
# $Id$
# elvis: translate -- Translate human languages (various providers)
. surfraw || exit 1
w3_config_hook () {
def SURFRAW_translate_provider babelfish
def SURFRAW_translate_from "$SURFRAW_lang"
def SURFRAW_translate_to "$SURFRAW_lang"
}
w3_usage_hook () {
cat <<EOF
Usage: $w3_argv0 [options] [words|URI]...
Description:
Surfraw translate human language
Local options:
-from=LANGUAGE Source language
Environment: SURFRAW_translate_from, SURFRAW_lang
-to=LANGUAGE Destination language
Environment: SURFRAW_translate_to, SURFRAW_lang
-provider= Translation service provider
babelfish babelfish.yahoo.com (systrans)
raging babelfish.yahoo.com/raging (systrans)
google http://translate.google.com
Default: $SURFRAW_translate_provider
Environment: SURFRAW_translate_provider
Languages (any provider):
nl Dutch
en English
fr French
de German
el Greek
it Italian
ja Japanese
ko Korean
pt Portuguese
ru Russian
es Spanish
Languages (Systrans only):
zh Chinese (Simplified)
zt Chinese (Traditional)
Languages (Google only):
auto Automatically detect language
af Afrikaans
sq Albanian
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bg Bulgarian
ca Catalan
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
hr Croatian
cs Czech
da Danish
et Estonian
tl Filipino
fi Finnish
gl Galician
ka Georgian
ht Hatian Creole
iw Hebrew
hi Hindi
hu Hungarian
is Icelandic
id Indonesian
ga Irish
la Latin
lv Latvian
lt Lithuanian
mk Macedonian
ms Malay
mt Maltese
no Norwegian
fa Persian
pl Polish
ro Romanian
sr Serbian
sk Slovak
sl Slovenian
sw Swahili
sv Swedish
th Thai
tr Turkish
uk Ukrainian
ur Urdu
vi Vietnamese
cy Welsh
yi Yiddish
Examples:
$w3_argv0 Provider's standard translation page
$w3_argv0 -provider=raging Use raging search as a translation provider
$w3_argv0 -from=fr -to=en la verite vous liberera
$w3_argv0 -from=en -to=es http://tashian.com/multibabel
Translate the given Web page
Bugs:
Systrans derived providers only support the following translation
combinations:
English to Chinese
English to French
English to German
English to Italian
English to Japanese
English to Korean
English to Portuguese
English to Spanish
Chinese to English
French to English
French to German
German to English
German to French
Italian to English
Japanese to English
Korean to English
Portuguese to English
Russian to English
Spanish to English
EOF
w3_global_usage
}
w3_parse_option_hook () {
opt="$1"
optarg="$2"
case "$opt" in
-from=*) setopt SURFRAW_translate_from $optarg ;;
-to=*) setopt SURFRAW_translate_to $optarg ;;
-provider=*) setopt SURFRAW_translate_provider $optarg ;;
*) return 1 ;;
esac
return 0
}
w3_config
w3_parse_args "$@"
# w3_args now contains a list of arguments
if [ "$SURFRAW_translate_provider" = "google" ]
then
if test -z "$w3_args"
then w3_browse_url "http://translate.google.com/"
else
if [ -z "$SURFRAW_translate_to" ];
then
SURFRAW_translate_to="en"
fi
if [ -z "$SURFRAW_translate_from" ];
then
SURFRAW_translate_from="fr"
fi
escaped_args=`w3_url_of_arg $w3_args`
case "$escaped_args" in
http*) w3_browse_url "http://translate.google.com/translate?&sl=${SURFRAW_translate_from}&tl=${SURFRAW_translate_to}&u=${escaped_args}"
;;
*) w3_browse_url "http://translate.google.com/?&sl=${SURFRAW_translate_from}&tl=${SURFRAW_translate_to}&q=${escaped_args}"
;;
esac
fi
else
if test -z "$w3_args"
then w3_browse_url "http://babelfish.yahoo.com/"
else
if [ -z "$SURFRAW_translate_to" ];
then
SURFRAW_translate_to="en"
fi
if [ -z "$SURFRAW_translate_from" ];
then
SURFRAW_translate_from="fr"
fi
escaped_args=`w3_url_of_arg $w3_args`
case "$escaped_args" in
http*) w3_browse_url "http://babelfish.yahoo.com/translate_url?tt=url&url=${escaped_args}&lp=${SURFRAW_translate_from}_${SURFRAW_translate_to}"
;;
*) w3_browse_url "http://babelfish.yahoo.com/translate_txt?doit=done&tt=urltext&intl=1&urltext=${escaped_args}&lp=${SURFRAW_translate_from}_${SURFRAW_translate_to}"
;;
esac
fi
fi
exit $?
|