Overview

Translations created by Canvas Translate keep und as their translation source metadata. ApiTranslateController::applyDraftToTarget() (1.0.x, lines 819–820) intends to set content_translation_source when publishing a draft, guarded by $target->get('content_translation_source')->isEmpty(). The guard never fires: the target translation is created with addTranslation($langcode, $stored->toArray()), which copies the source entity's content_translation_source value — und, the field's default. und is a value, not an empty field, so isEmpty() returns FALSE.

Two consequences:

  • The translate overview shows an unknown source for translations created by this module.
  • Any later code that saves such a translation object directly — while the field has content_translation translation_sync settings, which Canvas pages have by default since canvas#3591745 — triggers core's FieldTranslationSynchronizer exception: Invalid translation language (und) specified. Canvas Translate itself is not affected (it saves through the default translation), but the stored und is a latent trap for other modules and custom code.

Steps to reproduce

  1. Install canvas, canvas_translate, language, content_translation; add a second language; enable translation for Canvas pages.
  2. Create a Canvas page, translate it with Canvas Translate, publish the translation.
  3. Inspect the translation's content_translation_source field: it is und instead of the source langcode.

Proposed resolution

Compare against LanguageInterface::LANGCODE_NOT_SPECIFIED instead of (or in addition to) isEmpty(), so the source langcode is written both when the field is empty and when it holds the und default.

User interface changes

None.

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

penyaskito created an issue. See original summary.

lauriii made their first commit to this issue’s fork.

  • lauriii committed 14002040 on 1.0.x
    fix: #3609434 content_translation_source stays und for translations...
lauriii’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.