Added some slight error handling

This commit is contained in:
Andrew S. Rightenburg 2023-09-25 12:54:37 +08:00
parent 0b0cfefecb
commit 43f658ccc5
Signed by: rail5
GPG Key ID: A0CB570AB6629159
2 changed files with 13 additions and 1 deletions

7
debian/changelog vendored
View File

@ -1,3 +1,10 @@
stranslate (1.1) stable; urgency=medium
* Added some small semi error handling. Will flesh out
more fully later on.
-- rail5 <andrew@rail5.org> Mon, 25 Sep 2023 12:53:51 +0800
stranslate (1.0) bullseye; urgency=low
* Added Debian packaging to the stranslate script

View File

@ -3,7 +3,12 @@
CACHE_DIR="$HOME/.cache/stranslate/"
get_translation() {
curl -s -F "from=${from_language}" -F "to=${to_language}" -F "text=${input}" https://simplytranslate.org/"${engine}" | grep -Poe "readonly>.*</textarea>" | sed -e "s/readonly>//g" | sed -e "s/<\/textarea>//g"
translation=$(curl -s -F "from=${from_language}" -F "to=${to_language}" -F "text=${input}" https://simplytranslate.org/"${engine}" | grep -Poe "readonly>.*</textarea>" | sed -e "s/readonly>//g" | sed -e "s/<\/textarea>//g")
if [ "$translation" = "" ]; then
echo "stranslate: Error getting translation"
else
echo "$translation"
fi
}
get_languages() {