dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles # fast
git clone https://src.adamsgaard.dk/dotfiles.git # slow
Log | Files | Refs | README | LICENSE Back to index

commit c54938b79dbb3c1705eb60c540c37cfdd43c5e45
parent c6548e0dd37343e56337e504f5c99fdcb1db81e2
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Thu,  4 Mar 2021 19:45:01 +0100

add translate frontend for libretranslate.com

Diffstat:
A.local/bin/translate | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/.local/bin/translate b/.local/bin/translate @@ -0,0 +1,13 @@ +#!/bin/sh + +if [ $# -ne 2 ]; then + printf 'usage: translate srclang destlang\n\n' >&2 + exit 1 +fi + +curl -s \ + -X POST "https://libretranslate.com/translate" \ + -H "accept: application/json" \ + -H "Content-Type: application/x-www-form-urlencoded" \ + -d "q=$(sed 's, ,%20,g')&source=${1}&target=${2}&api_key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" |\ + awk -F'"' '/translatedText/ { print $4 }'