qutebrowser: Fix git tracking, Add translate script

Added script to quickly translate a page or selected text through google
translate. Can be invoked through the aliases `:translate-page` or `:translate-selection` respectively, or the shortcuts <leader>bg, <leader>bG.

Added some gitignore files in the directory to stop keeping track of
non-personal configuration files.
This commit is contained in:
Marty Oehme 2020-11-13 09:34:52 +01:00
parent bc534e2026
commit 845b98d22d
Signed by: Marty
GPG key ID: B7538B8F50A1C800
5 changed files with 83 additions and 15 deletions

View file

@ -0,0 +1,51 @@
#!/usr/bin/env sh
#
# Translate the page, or if `--text` argument is given the current selection, with google translate.
#
# Adapted code from https://github.com/AckslD/Qute-Translate, with much gratitude.
while [ $# -gt 0 ]; do
case $1 in
-s | --source)
QUTE_TRANS_SOURCE=$2
shift
shift
;;
-t | --target)
QUTE_TRANS_TARGET=$2
shift
shift
;;
--url)
QUTE_TRANS_URL="true"
shift
;;
--text)
QUTE_TRANS_URL="false"
shift
;;
esac
done
if [ -z "$QUTE_TRANS_SOURCE" ]; then
# Default use automatic language for source
QUTE_TRANS_SOURCE="auto"
fi
if [ -z "$QUTE_TRANS_TARGET" ]; then
# Default use English for target
QUTE_TRANS_TARGET="en"
fi
if [ "$QUTE_TRANS_URL" = "false" ]; then
# Translate selected text
PAGE="https://translate.google.com/#view=home&op=translate&"
CONT_KEY="text"
CONTENT=$QUTE_SELECTED_TEXT
else
# Default translate URL
PAGE="https://translate.google.com/translate?"
CONT_KEY="u"
CONTENT=$QUTE_URL
fi
echo "open -t ${PAGE}sl=$QUTE_TRANS_SOURCE&tl=$QUTE_TRANS_TARGET&$CONT_KEY=$CONTENT" >>"$QUTE_FIFO"