Hello and thanks for the efforts with this module!
I'm using the dev version of the module and after the changes made in this issue https://www.drupal.org/project/ai_provider_deepl/issues/3553315 I'm getting an error when trying to translate any text with DeepL.
The translation failed and the service returned the following error: DeepL\LanguageCode::removeRegionalVariant(): Argument #1 ($langCode) must be of type string, null given, called in /var/www/html/web/modules/contrib/ai_provider_deepl/src/Plugin/AiProvider/DeepLProvider.php on line 135
I don't know why, but sometimes the source language can be null, and it causes the problem here:
$sourceLanguage = LanguageCode::removeRegionalVariant($input->getSourceLanguage());
removeRegionalVariant() method seems to come from DeepL php library so I don't think we can change it. But maybe we could add some checking in translateText() of ai_provider_deepl module instead?
Issue fork ai_provider_deepl-3557140
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
hartsak commentedI tried to add some kind of solution in my merge request in branch 3557140-error-when-source-langcode-is-null. Please have a look at it! Thanks!
(And sorry, I think I accidentally somehow created another branch 3557140-error-translating-when but I couldn't delete it. So I think it can be ignored...)
Comment #5
jhuhta commentedLooks good, merging. Thanks!
Comment #7
jhuhta commentedComment #9
hartsak commentedThat was fast, thanks a lot @jhuhta!