22-08-2024
This commit is contained in:
17
api_deepl.sh
Executable file
17
api_deepl.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
[ ! -f "$HOME/.env" ] || export $(grep -v '^#' "$HOME/.env" | xargs)
|
||||
|
||||
# DE/FR/ES/EN-GB/EN-US
|
||||
|
||||
translate() {
|
||||
|
||||
deepl=$(curl -s -X POST 'https://api-free.deepl.com/v2/translate' \
|
||||
--header "Authorization: DeepL-Auth-Key $DEEPL_KEY" \
|
||||
--data-urlencode "text=$2" \
|
||||
--data-urlencode "target_lang=$1"
|
||||
)
|
||||
echo "$deepl" | jq -r .'translations[].text'
|
||||
}
|
||||
|
||||
translate "DE" "il fait beau !"
|
||||
Reference in New Issue
Block a user