Hi, I have the following script that works flawlessly when the API key for DeepL is written into the script. It does not work however when using os.getenv('DEEPL_API_KEY', ''). The environment variable is properly set.
# #popclip
# popclip version: 4069
# name: DeepL β English
# icon: iconify:twemoji:flag-united-kingdom
# interpreter: /Users/***/***/***/venv/bin/python3
# after: preview-result
import deepl # https://github.com/DeepLcom/deepl-python
import os
auth_key = os.getenv('DEEPL_API_KEY', '').strip()
translator = deepl.Translator(auth_key)
originaltext = os.environ['POPCLIP_TEXT']
result = translator.translate_text(originaltext, source_lang="DE", target_lang="EN-GB")
print(result.text, end="")
I assume my ~/.zshrc is not used because of the way PopClip runs scripts? Any ideas how to fix this? Thanks!
Kolkrabe