Adding new content via JSON:API results in no immediate translation

Created on 30 June 2023, over 1 year ago
Updated 3 July 2023, over 1 year ago

Problem/Motivation

I have setup "Continuous Job" to translate from EN do DE including taxonomy terms. After creating new content in EN via JSON:API, in my case - taxonomy term, it's translation status hang on stage "In progress", immediate translation is not working. In Settings i disabled option "Submit continuous job items on cron", meaning translation should be made on content creation. JSON:API creates new content (POST request) in source language EN but DE translation is missing. I use "DeepL API Free" REST API key. I must add that when using Drupal administration panel, translation is added correctly after term creation. For authorization i use Bearer token and my role is Administrator so all permissions are sufficient.

Steps to reproduce

JSON:API payload:
{
"data": {
"attributes": {
"name": "Car",
"description": {
"value": "",
"format": "basic_html"
},
"revision_translation_affected": null
},
"relationships": {},
"type": "taxonomy_term--sm_industry"
}
}

JSON:API response:
{
"jsonapi": {
"version": "1.0",
"meta": {
"links": {
"self": {
"href": "http://jsonapi.org/format/1.0/"
}
}
}
},
"data": {
"type": "taxonomy_term--sm_industry",
"id": "db6dfbd0-ef5a-4448-9bb2-c8cc26f33dc1",
"links": {
"self": {
"href": "https://api.io/jsonapi/taxonomy_term/sm_industry/db6dfbd0-ef5a-4448-9bb2..."
}
},
"attributes": {
"drupal_internal__tid": 91,
"drupal_internal__revision_id": 300,
"langcode": "en",
"revision_created": "2023-06-30T16:45:15+00:00",
"revision_log_message": null,
"status": true,
"name": "Car",
"description": null,
"weight": 0,
"changed": "2023-06-30T16:45:15+00:00",
"default_langcode": true,
"revision_translation_affected": true,
"content_translation_source": "und",
"content_translation_outdated": false,
"content_translation_created": "2023-06-30T16:45:15+00:00"
},
"relationships": {
"vid": {
"data": {
"type": "taxonomy_vocabulary--taxonomy_vocabulary",
"id": "6ab2c17b-763f-4052-87bc-273f0453138e",
"meta": {
"drupal_internal__target_id": "sm_industry"
}
},
"links": {
"related": {
"href": "https://api.io/jsonapi/taxonomy_term/sm_industry/db6dfbd0-ef5a-4448-9bb2..."
},
"self": {
"href": "https://api.io/jsonapi/taxonomy_term/sm_industry/db6dfbd0-ef5a-4448-9bb2..."
}
}
},
"revision_user": {
"data": null,
"links": {
"related": {
"href": "https://api.io/jsonapi/taxonomy_term/sm_industry/db6dfbd0-ef5a-4448-9bb2..."
},
"self": {
"href": "https://api.io/jsonapi/taxonomy_term/sm_industry/db6dfbd0-ef5a-4448-9bb2..."
}
}
},
"parent": {
"data": [
{
"type": "taxonomy_term--sm_industry",
"id": "virtual",
"meta": {
"links": {
"help": {
"href": " https://www.drupal.org/docs/8/modules/json-api/core-concepts#virtual ",
"meta": {
"about": "Usage and meaning of the 'virtual' resource identifier."
}
}
}
}
}
],
"links": {
"related": {
"href": "https://api.io/jsonapi/taxonomy_term/sm_industry/db6dfbd0-ef5a-4448-9bb2..."
},
"self": {
"href": "https://api.io/jsonapi/taxonomy_term/sm_industry/db6dfbd0-ef5a-4448-9bb2..."
}
}
},
"content_translation_uid": {
"data": {
"type": "user--user",
"id": "a43c44e1-4135-47b7-87d1-c9a6c0e3c37e",
"meta": {
"drupal_internal__target_id": 1
}
},
"links": {
"related": {
"href": "https://api.io/jsonapi/taxonomy_term/sm_industry/db6dfbd0-ef5a-4448-9bb2..."
},
"self": {
"href": "https://api.io/jsonapi/taxonomy_term/sm_industry/db6dfbd0-ef5a-4448-9bb2..."
}
}
}
}
},
"links": {
"self": {
"href": "https://api.io/jsonapi/taxonomy_term/sm_industry"
}
}
}

Proposed resolution

I am trying to find out what event/hook invokes the translation to estimate if invoking handler is not takin into account JSON:API. Since JSON:API is based on Entity API i assume fixture should be relatively simple.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Closed: works as designed

Version

1.15

Component

Miscellaneous

Created by

🇵🇱Poland Pozi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Pozi
  • 🇵🇱Poland Pozi

    It is also worth mentioning that EN is my default language on site. I am aware of JSON:API limitation when it comes to translations creation but as far i understand how TMGMT works, translation is added on Drupal "side" as "reaction" to node creation.
    https://www.drupal.org/docs/core-modules-and-themes/core-modules/jsonapi...

  • 🇵🇱Poland Pozi

    So far i managed to establish that hook "tmgmt_content_entity_update()" from tmgmt/sources/content/tmgmt_content.module is not fired when addin content via JSON:API. But at the moment i am not sure where newly created entity update occurs.

    Adding new content backtrace:

    via JSON:API:
    1) tmgmt_content_entity_update() :: entityId: 491, getEntityTypeId: tmgmt_job_item, bundle: tmgmt_job_item, source_langcode: und
    Missing hook invokation for just added custom node type "sm_training_unit"!

    via CMS interface:
    1) tmgmt_content_entity_update() :: entityId: 492, getEntityTypeId: tmgmt_job_item, bundle: tmgmt_job_item, source_langcode: und
    2) tmgmt_content_entity_update() :: entityId: 492, getEntityTypeId: tmgmt_job_item, bundle: tmgmt_job_item, source_langcode: und
    3) tmgmt_content_entity_update() :: entityId: 46, getEntityTypeId: node, bundle: sm_training_unit, source_langcode: de
    4) tmgmt_content_entity_update() :: entityId: 492, getEntityTypeId: tmgmt_job_item, bundle: tmgmt_job_item, source_langcode: und
    5) tmgmt_content_entity_update() :: entityId: 492, getEntityTypeId: tmgmt_job_item, bundle: tmgmt_job_item, source_langcode: und

  • 🇵🇱Poland Pozi

    I made a test with another Provider - Google and it worked so the problem is within provider module - DeepL.

  • Status changed to Closed: works as designed over 1 year ago
Production build 0.71.5 2024