I got the error:
TypeError: Return value of Drupal\Component\Utility\Html::decodeEntities() must be of the type string, null returned in /var/www/html/web/core/lib/Drupal/Component/Utility/Html.php on line 390 #0 /var/www/html/web/modules/contrib/tmgmt_deepl/src/Plugin/tmgmt/Translator/DeeplTranslator.php(301)
We should add a condition before decoding, because the string is not always transmitted, in my case it is an array.

Command icon 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

dima.iluschenko created an issue. See original summary.

dima.iluschenko’s picture

StatusFileSize
new819 bytes

Attached the patch for skipping all except a string.

steffenr’s picture

Thanks for the finding. You are the first one having problems with the notation in the module. Could you be a little more specific, what kind of data you try to translate or when the error happens (maybe you could add a debug breakpoint before).

Do you also have this problem with the tmgmt_google module - this uses the same logic as tmgmt_deepl.

I'll check your patch and bring it in the next release of the module (looks fine so far)..

dima.iluschenko’s picture

Issue summary: View changes
StatusFileSize
new230.68 KB
new992.73 KB

Hi dear @SteffenR. I identified a problem. It relates to the combined field. In my case it was Mask Icon field from the Meta Tags module:
Mask Icon
Mask Icon

I believe we have to fix it in tmgmt module. I'll create an issue and attach the patch soon.

steffenr’s picture

Hi Dima,

Thanks for clarification. In this case it would make more sense, to declare this field as being non-translatable.
Just use the hook_tmgmt_translatable_fields_alter to remove those fields from your translatable fields like shown in the example:

/**
 * Implements hook_tmgmt_translatable_fields_alter().
 */
function custom_module_tmgmt_translatable_fields_alter(ContentEntityInterface $entity, array &$translatable_fields): void {
  // No translation for following fields.
  $not_translatable_fields = ['field_mask_icon', 'field_my_custom_field'];

  foreach ($translatable_fields as $field_name => $translatable_field) {
    // Unset fields that won't be available in translation.
    if (in_array($field_name, $not_translatable_fields)) {
      unset($translatable_fields[$field_name]);
    }
  }
}

You can use unset here or just set #translatable to false.

dima.iluschenko’s picture

Hi Steffen,

It's good that we can exclude fields from the translations. However, we shouldn't get php error and see a broken process during translation for contrib modules.

dima.iluschenko’s picture

@SteffenR Also we can't exclude only mask_icon in hook_tmgmt_translatable_fields_alter. We can exclude the entire meta tag field, so that won't help with my problem.

steffenr’s picture

@dima.iluschenko:
You are right. The patch was already applied to the latest version of the module.
https://git.drupalcode.org/project/tmgmt_deepl/-/tree/2.1.9

Thanks for the finding.

steffenr’s picture

Status: Active » Fixed
steffenr’s picture

Status: Fixed » Closed (fixed)