author

Self-Hosting, Minimalism, Linux, .NET, Philosophy, Psychology, Privacy, Security.

Join us on XMPP!

Her.st Propaganda Stream

Her.st Translation + API

URL: web

URL: API

curl https://trap.her.st/api/translate/?engine=google&to=en&text=Recuerdo+los+tiempos

API Quickstart

Ex: curl https://trap.her.st/api/target_languages.

Translate

Path https://trap.her.st/api/translate/

  • [required] engine [google, libre, DeepL, ICIBA ]
  • [optional] from
  • [required] to
  • [required] text

Ex: https://trap.her.st/api/translate/?engine=google&from=en&to=es&text=Hello

Get Languages

Path https://trap.her.st/api/get_languages/

  • [required] engine [google, libre, DeepL, ICIBA ]

Ex: https://trap.her.st/api/get_languages/?engine=google

Text-To-Speech (TTS)

Path https://trap.her.st/api/tts/

  • [required] engine [google, libre, DeepL, ICIBA ]
  • [required] lang
  • [required] text

Ex: https://trap.her.st/api/tts/?engine=google&lang=en&text=Hello

Sample


# dependencies for this example
# sudo apt install curl jq rofi xdotool
# sudo pacman -S curl jq rofi xdotool

languages="
Arabic ar
Belarusian be
Chinese zh-CN
Taiwanese zh-TW
Croatian hr
Czech cs
Danish da
Dutch nl
English en
Estonian et
Finnish fi
French fr
German de
Greek el
Hebrew iw
Hungarian hu
Italian it
Japanese ja
Korean ko
Latin la
Norwegian no
Persian fa
Polish pl
Portuguese pt
Punjabi pa
Romanian ro
Russian ru
Serbian sr
Slovak sk
Slovenian sl
Spanish es
Swedish sv
Turkish tr
Ukrainian uk
Yiddish yi
"

# turn languages into lowercase
languages=( "${languages[@],,}" )

# display language selection menu
lang=$(echo "$languages" | rofi -dmenu | cut -d ' ' -f 2)

if [ -z "$lang" ]; then
    exit 0
fi

# display text input box
text=$(rofi -dmenu -p "Text to translate:")

if [ -z "$text" ]; then
    exit 0
fi

json=$(curl -s "https://trap.her.st/api/translate/?engine=google" --data-urlencode "to=$lang" --data-urlencode "text=$text")
translation=$(echo $json | jq -r '.["translated-text"]')
xdotool type "$translation"