Is there a way to use the deepl Python client library (or raw API) to detect the source language (without translating it)? The marketing blurb on the API website says, detection is available but I can't find it anywhere in the library or API.
-
Can you tell me a bit more about what you're trying to achieve and maybe I can help you :) – Tim Cadenbach Nov 18 '22 at 23:39
-
I'm thinking about a solution for mastodon. Currently people have to manually label their toots (posts) with a language, but many don't. I was thinking if one could use deepl for language detection since mastodon is already using deepl for translation. – Bastian Venthur Nov 19 '22 at 09:09
-
1Thats an interesting idea, while the API currently does not have that functionality I can totally see how it could be useful, let me ask the devs about this. – Tim Cadenbach Nov 19 '22 at 10:50
2 Answers
Currently, our API does not support "just" detecting the language. Our recommendation would be to try translating a small part of the sentence and use the detected language from the response.
Even if we had a separate /detectLanguage endpoint, using it would be similar to this approach as you had to send some text anyway.

- 1,446
- 1
- 9
- 21
I worked quite some time with deepl due to its simplicity, to be honest, I don't think deepl has that feature as a standalone function. But if you send a request to translate you will get the detected language in the response. If you have the starter package you can translate unlimited texts, so this might be a viable workaround.
If you are open to another tool, LibreTranslate has a detect endpoint but the pricing is a bit more expensive. However, you can host it yourself if you have the infrastructure for it. https://libretranslate.com/docs/

- 323
- 3
- 15