Made note and added ltranslate script

This commit is contained in:
z3rOR0ne 2022-11-10 19:36:14 -08:00
parent 84bac7896a
commit ab02176c06
2 changed files with 41 additions and 2 deletions

39
scripts/ltranslate Executable file
View file

@ -0,0 +1,39 @@
#!/usr/bin/env bash
# set -vx
if [ $# -lt 3 ]; then
printf "not enough arguments given\n\
usage: ltranslate sourcelang targetlang query\n"
exit 1
fi
dependencycheck() {
numdependencies="$#"
dependencies=("$@")
missingdependencies=0
for ((i = 0; i < numdependencies; i++)) ; do
if ! command -v "${dependencies[$i]}" &> /dev/null ; then
printf "dependency not met: %s" "${dependencies[$i]}"
missingdependencies=$((missingdependencies+1))
fi
done
if [ $missingdependencies -gt 0 ]; then
exit 1
fi
}
dependencycheck curl awk sed
ua='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'
url="https://libretranslate.de/translate"
headers="Content-Type: application/json"
source=$1
target=$2
query="${*:3}"
main() {
result=$(curl -sAX POST "${ua}" "${url}" -H "${headers}" -d '{"q": "'"${query}"'", "source": "'"${source}"'", "target": "'"${target}"'"}' | awk -F ':' '{ print $2 }' | sed 's/"//g; s/}//g')
printf '%s'"${result}\n"
}
main

View file

@ -186,6 +186,6 @@ paru dirb (1st option)
Go to Chrome store and install CSS Dig on brave
Install slop and gifsicle and libimage-exiftool-perl
Install slop and gifsicle and libimage-exiftool-perl and rebuild-detector
doas pacman -S slop gifsicle libimage-exiftool-perl
doas pacman -S slop gifsicle libimage-exiftool-perl rebuild-detector