DeepLcom / deepl-node

Official Node.js library for the DeepL language translation API.
MIT License
371 stars 22 forks source link

Bad request on unsupported formality #1

Closed mattbrannon closed 2 years ago

mattbrannon commented 2 years ago

Currently, a request that specifies a formality setting not yet supported by DeepL returns an error without a translation. DeepLError: Bad request, message: 'formality' is not supported for given 'target_lang'.

Maybe a more user friendly alternative would be to just ignore any unsupported options in the request, possibly attaching a warning message to the response informing the user of their mistake. This way, applications that call the DeepL api won't break when supplied an invalid configuration.

daniel-jones-deepl commented 2 years ago

Hi Matt, this is a good suggestion, thanks.

It will take some time to change to our backend; I'll post an update when it is changed.

TasseDeCafe commented 2 years ago

I just want to add my support for this feature, it would be easier to set up the requests that way.

daniel-jones-deepl commented 2 years ago

Hello again, we've added two new allowed formality values: prefer_less and prefer_more. They have the same function as less and more respectively if the target language supports formality, otherwise they fallback to the default formality. With these two values you will not get the error mentioned above.