-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibretranslate
More file actions
executable file
·46 lines (43 loc) · 852 Bytes
/
libretranslate
File metadata and controls
executable file
·46 lines (43 loc) · 852 Bytes
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
if [ $LIBRETRANSLATE_URL ]
then
url=$LIBRETRANSLATE_URL
else
url="https://translate.argosopentech.com/"
fi
if [ $LIBRETRANSLATE_API_KEY ]
then
api_key_flag="-F \"api_key=${$LIBRETRANSLATE_API_KEY}\""
else
api_key_flag=""
fi
curl_args="--silent --show-error "
fun=$1
if [ $fun == "translate" ]
then
source=$2
target=$3
q=$4
curl -X POST \
$curl_args \
-F "q=$q" \
-F "source=$source" \
-F "target=$target" \
$api_key_flag \
"${url}translate"
elif [ $fun == "detect" ]
then
q=$2
curl -X POST \
$curl_args \
-F "q=$q" \
$api_key_flag \
"${url}detect"
elif [ $fun == "languages" ]
then
curl -X POST \
$curl_args \
"${url}languages"
else
echo "Invalid function"
exit 1
fi