Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Bad request, message: Document is empty #103

Closed
ccaneke opened this issue Apr 22, 2024 · 4 comments
Closed

Error: Bad request, message: Document is empty #103

ccaneke opened this issue Apr 22, 2024 · 4 comments

Comments

@ccaneke
Copy link

ccaneke commented Apr 22, 2024

deepl --auth-key <zip> document --to=DE John,Doe.pdf

deepl command above fails to translate a document, instead outputs the error:

Error: Bad request, message: Document is empty

My system is fedora linux and deepl version is deepl-python v1.17.0.

@JanEbbing
Copy link
Member

Hi, I assume bash is picking up John,Doe.pdf as 2 separate inputs, as the document subcommand requires 2 positional arguments, one for the input file and one for the output file. See the help output:

$ deepl document --help
usage: deepl document [-h] --to TARGET_LANG [--from SOURCE_LANG]
                      [--formality {less,default,more,prefer_more,prefer_less}]
                      [--glossary-id GLOSSARY] [--output-format OUTPUT_FORMAT]
                      file [file ...] dest

translate document(s)

positional arguments:
  file                  file(s) to be translated.
  dest                  destination directory to store translated files.

optional arguments:
  -h, --help            show this help message and exit
  --to TARGET_LANG, --target-lang TARGET_LANG
                        language into which the text should be translated
  --from SOURCE_LANG, --source-lang SOURCE_LANG
                        language of the text to be translated; unless using a
                        glossary, this argument is optional and if it is
                        omitted DeepL will auto-detect the source language.
  --formality {less,default,more,prefer_more,prefer_less}
                        desired formality for translation
  --glossary-id GLOSSARY
                        ID of glossary to use for translation
  --output-format OUTPUT_FORMAT
                        output file extension

The correct command would probably be deepl --auth-key <zip> document --to=DE "John,Doe.pdf" "John,Doe_TRANSLATED.pdf"

@ccaneke
Copy link
Author

ccaneke commented Apr 22, 2024

I misunderstood dest as the location of deepl's output. For some reason I thought deepl would name the translated file something like John,Doe_de.pdf. That's why I wrongly entered the current directory ..

@ccaneke ccaneke closed this as completed Apr 22, 2024
@JanEbbing
Copy link
Member

Upon rereading, that is kind of what the help states (incorrectly). I will fix the wording here, thanks!

@JanEbbing
Copy link
Member

JanEbbing commented Apr 22, 2024

I just checked the code - the command I suggested works as well, but the intention is to provide a directory (as you can provide multiple documents as input), and it will create one file per input file with the same name in this directory (so, if the file is in the current directory, . as the output directory might lead to errors, as the paths will collide.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants