This commit is contained in:
parent
c449dfcb5f
commit
559939e2f4
49 changed files with 729 additions and 252 deletions
30
.local/bin/scripts/promt
Executable file
30
.local/bin/scripts/promt
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
tmpfile="$(mktemp)"
|
||||
if [ -t 0 ]; then
|
||||
[ "$#" = 0 ] && exit 1
|
||||
echo "$@" > "$tmpfile"
|
||||
else
|
||||
cat > "$tmpfile"
|
||||
case "$1" in
|
||||
r*) dir=en-ru;;
|
||||
e*) dir=ru-en;;
|
||||
esac
|
||||
fi
|
||||
|
||||
[ -z "$dir" ] &&
|
||||
if (( $(grep -oP '\p{Latin}' < "$tmpfile" | wc -l) > $(grep -oP '\p{Cyrillic}' < "$tmpfile" | wc -l) )); then
|
||||
dir='en-ru'
|
||||
else
|
||||
dir='ru-en'
|
||||
fi
|
||||
|
||||
curl -s \
|
||||
http://ядро.орг:9000/translate \
|
||||
-H 'Content-Type: text/html' \
|
||||
-H "X-Translation-Direction: $dir" \
|
||||
--data-binary @- -o- < "$tmpfile" | \
|
||||
tail -n +2 | \
|
||||
perl -pe 's,<SPAN CLASS=UNKNOWN_WORD>(.*?)</SPAN>,\1,g' |
|
||||
sed -e 's/>/>/g' -e 's/</</g' -e 's/"/"/g'
|
||||
echo
|
||||
Loading…
Add table
Add a link
Reference in a new issue