DeepLcom / deepl-php

Official PHP library for the DeepL language translation API.
MIT License
202 stars 23 forks source link

Allow to translate empty strings #24

Closed VincentLanglet closed 1 year ago

VincentLanglet commented 1 year ago

Hi @JanEbbing

Currently an exception is thrown when we try to translate an empty string. This seems to be an unnecessary check because if I remove the check manually in my vendors, the API works fine.

When receiving multiple users inputs and if we want to translate for instance

['foo', 'bar', '', 'baz']

This seems unnecessary to ask us to

While an API call with ['foo', 'bar', '', 'baz'] seems to works fine if the input validation is removed.

JanEbbing commented 1 year ago

Thanks for this! I agree the behaviour is inconsistent, e.g. in deepl-python translating '' raises an error but translating [''] works fine. I'm checking internally why we don't allow empty string and how we want to handle this, let me get back to you.

JanEbbing commented 1 year ago

Agreed that we should allow translating empty string. I'll merge this