friebetill / obsidian-deepl

DeepL for Obsidian.
MIT License
46 stars 6 forks source link

Limitation of allowed selected characters per query #13

Open without-qualities opened 4 months ago

without-qualities commented 4 months ago

If I try to translate a longer section, the translation doesn't go through and following message appears:

"Please try again with a shorter text"

As far as I understand the free version of the DeepL API key allows for 500000 chars/month. Is there an additional limit per query, or this is a limitation of obsidian or the plugin?

dario-baumberger commented 4 months ago

I'm not the developer of this Plugin. I just contribute a small part. I had a look at the code.

The message "Please try again with a shorter text" is implemented by the DeepL Plugin: https://github.com/friebetill/obsidian-deepl/blob/7c7f5b2c0248f5db3a8a8156e4de7977c7b90231/src/deepl/deeplException.ts#L24-L26

This message corresponds to the error code 413: https://github.com/friebetill/obsidian-deepl/blob/7c7f5b2c0248f5db3a8a8156e4de7977c7b90231/src/deepl/deeplErrorCodes.ts#L6

Error code 413 is returned from DeepL API: https://support.deepl.com/hc/en-us/articles/9773964275868-DeepL-API-error-messages:

Error 413 The request size exceeds the limit This error occurs when the request size reaches the supported limit. Please consult the API documentation for detailed information about size limits, particularly for document translations. If you are trying to translate a large text in a single translation request, consider splitting it up into multiple requests, e.g., split it by paragraph.

To answer your question: Based on the error code, the limit comes from the DeepL API. I have not seen any additional limitations from the plugin. Obsidian itself has nothing to do with this.