Skip to content

Commit 0768106

Browse files
2.0.2: add more debugging information
1 parent fe0980e commit 0768106

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

Deepl-Translate.alfred5workflow

56 Bytes
Binary file not shown.

Deepl-Translate.alfredworkflow

57 Bytes
Binary file not shown.

deepl.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,23 @@ if [ -n "$KEY" ]; then
8686
else
8787
url="https://api-free.deepl.com/v2/translate"
8888
fi
89+
echo >&2 "curl -s -X POST '$url' -H 'Authorization: DeepL-Auth-Key $KEY' -d 'text=$query' -d 'target_lang=${LANGUAGE:-EN}'"
8990
result=$(curl -s -X POST "$url" -H "Authorization: DeepL-Auth-Key $KEY" -d "text=$query" -d "target_lang=${LANGUAGE:-EN}")
91+
echo >&2 "$result"
9092
osascript -l JavaScript -e 'function run(argv) {
9193
const translations = JSON.parse(argv[0])["translations"].map(item => ({
9294
title: item["text"],
9395
arg: item["text"]
9496
}))
9597
9698
return JSON.stringify({ items: translations }, null, 2)
97-
}' "$result" || echo >&2 "ERROR: Input '$result'"
99+
}' "$result" || echo >&2 "ERROR w/ key: result '$result', query '$query'"
98100
else
101+
echo >&2 "curl -s 'https://www2.deepl.com/jsonrpc' '${HEADER[@]}' --data-binary $'$data'"
99102
result=$(curl -s 'https://www2.deepl.com/jsonrpc' \
100103
"${HEADER[@]}" \
101104
--data-binary $"$data")
105+
echo >&2 "$result"
102106
if [[ $result == *'"error":{"code":'* ]]; then
103107
message="$(osascript -l JavaScript -e 'function run(argv) { return JSON.parse(argv[0])["error"]["message"] }')"
104108
printJson "Error: $message"
@@ -110,7 +114,7 @@ else
110114
}))
111115
112116
return JSON.stringify({ items: translations }, null, 2)
113-
}' "$result" || echo >&2 "ERROR: Input '$result'"
117+
}' "$result" || echo >&2 "ERROR w/o key: result '$result', query '$query'"
114118
fi
115119
fi
116120
###############################################################################

info5.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ To avoid the error message 'too many requests', please configure your free (or p
611611
<key>variablesdontexport</key>
612612
<array/>
613613
<key>version</key>
614-
<string>2.0.1</string>
614+
<string>2.0.2</string>
615615
<key>webaddress</key>
616616
<string>https://github.com/AlexanderWillner/deepl-alfred-workflow2</string>
617617
</dict>

0 commit comments

Comments
 (0)