1
0
Fork 0
This commit is contained in:
Arthur K. 2026-01-06 07:36:53 +03:00
parent c449dfcb5f
commit 559939e2f4
Signed by: wzray
GPG key ID: B97F30FDC4636357
49 changed files with 729 additions and 252 deletions

30
.local/bin/scripts/promt Executable file
View 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/&gt;/>/g' -e 's/&lt;/</g' -e 's/&quot;/"/g'
echo