blob: 55d65ee0148dd619cf10ae5c9bda2b8578a04bd0 (
plain)
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
|
#!/bin/sh
# Translate words using http://context.reverso.net and scraping the answers
# with 'pup' and 'curl'.
# returns available languages
languages () {
cat <<-EOF
arabic
dutch
french
german
polish
english
portuguese
spanish
romanian
hebrew
swedish
italian
turkish
japanese
ukrainian
korean
chinese
czech
hungarian
danish
persian
greek
slovak
hindi
thai
EOF
}
if [ -z "${word:=$1}" ]
then
>&2 printf '>'
word="$(head -n1)"
fi
[ "$word" ] || exit 1
primary="$(languages | fzf --prompt="from:")"
[ "$primary" ] || exit 1
secondary="$(languages | fzf --prompt="to:")"
[ "$secondary" ] || exit 1
curl -s "https://context.reverso.net/translation/$primary-$secondary/$word" \
--compressed \
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' \
-H 'Accept-Language: en-US,en;q=0.5' \
-H 'Accept-Encoding: gzip, deflate, br' |
pup 'a.link_highlighted em text{}' |
sed 's/.*/\L&/' |
sort | uniq | sed 's/.*/ &/'
|