Summary

The module almost works for this use case. But if you have a few canvas pages and then change the site default language, Canvas Translate will not allow to translate from each entity to their targets. It does identify which one was the source language and displays an error nicely when trying to translate to that. (Better would be if it would directly lead to editing that Canvas page). So there is already preparation for this but it then stopped short of working by not including the column when needed.

I understand Canvas currently assumes all pages are in site default, but it does not appear like Canvas Translate is too far from allowing canvas pages and config entities being translated in any language, similar to how Drupal normally does.

Once the MR is applied, I have this. In this instance I originally had an English site default, pages and config in English. Now I switched to Hungarian as site default and also added French. I added one more Hungarian page, now I translated the Hungarian page to English and the English config entities to Hungarian. All works with this tiny tiny MR :)

I can even preview the page in Hungarian (current site default but for this entity it is a translation) where the entity source was English (not anymore the site default):

Steps to reproduce

Proposed resolution

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

gábor hojtsy created an issue. See original summary.

gábor hojtsy’s picture

Status: Active » Needs review
gábor hojtsy’s picture

Issue summary: View changes
StatusFileSize
new582.85 KB
new2.47 MB
f0ns’s picture

Thank you for your work on this, I also need this for a project so I'll try to test this asap!

f0ns’s picture

I tested this on a fresh Drupal 11 install with only the needed modules installed.

Core 11.4.5, canvas 1.10.1, canvas_translate 1.0.0-alpha4, English (default) + Dutch, translation enabled for canvas_page.

Before: with one page created in nl and one in en, the dashboard only renders a Dutch column. The NL page shows "Source / Edit" and there's no English column, so it can't be translated. The API is already correct here. /canvas-translate/api/items returns:

"sourceLangcode": "nl",
"translations": {
  "nl": { "status": "source", "percent": 100 },
  "en": { "status": "not_translated", "percent": 0 }
}

So it really is just the frontend filter in Dashboard.tsx.

With MR !8: applies cleanly to alpha4, and includes the built dist/index.global.js so no rebuild is needed. Both columns show up, and I did a full NL to EN round trip (draft, then publish) that saved correctly on the entity:

langs: nl,en
en title: NL source page (EN)
nl title: NL bron pagina

Also checked with the site default switched to Dutch, which works, and confirmed no regression: when everything is sourced in the default language, that column stays hidden as before. All 32 kernel tests pass.

Two small things I noticed reading the diff:

  • configItems() does loadMultiple() and then loadOverrideFree($id) per entity, so each config entity is loaded twice. And since loadOverrideFree() can return NULL, the \assert() there won't catch it in production. A real continue check would be safer.
  • Trailing whitespace after the new useMemo's closing ); will trip the coding standards check.

I couldn't exercise the config path at runtime (a standard install has no content_template / page_region entities), so that side is code review only from me. Behaviour-wise this does exactly what the issue describes.

f0ns’s picture

I added the things I noticed to the MR.

Looks good now but I'll leave it on Needs review for now, this can use an extra pair of eyes.

lauriii’s picture

Status: Needs review » Needs work

We need to update the specs to account for this change. Once we have added the spec, we should add a test case verifying the spec. This makes this easier to review and ensures the specs in the repository do not drift.

f0ns’s picture

Thanks, specs and tests added in openspec/changes/per-item-source-language/. openspec validate --specs passes.

Writing it up showed the MR is three behaviour changes, so each got a requirement:

  • content-translation MODIFIED Translation dashboard: an item's source language is whatever it was authored in, so the site default becomes a target column when any item is sourced elsewhere, and stays out when none are. Two scenarios pin both directions.
  • config-translation MODIFIED Config layouts in the workspace: a layout's source is its own langcode. Content pages already did this; config was the outlier.
  • config-translation ADDED Config source strings are read override-free: the loadOverrideFree() half. Config loaded with overrides applied handed back the translation as the source, inflating completeness and hiding staleness.

Tests: two in ConfigTranslateWorkflowTest (a fr-sourced region on an en-default site; source strings unaffected by an existing override), plus extension/columns.test.ts, since the column logic is now a pure columns.ts like diff.ts and drafts.ts. Both kernel tests fail against the pre-MR controller and pass with it. Full run: 34 kernel, 39 Vitest.

Worth a review: sites with existing config overrides will now see lower completeness. Correct, but visible after upgrade.

f0ns’s picture

Status: Needs work » Needs review
f0ns’s picture

Testing note:

if your site default language differs from a page's source language, the editor will not offer the translation for publishing.

That is unrelated to this branch, tracked in https://git.drupalcode.org/project/canvas/-/work_items/3591703

gábor hojtsy’s picture

Priority: Normal » Major
StatusFileSize
new241.06 KB

Canvas can now create Canvas pages in ANY LANGUAGE, so this is a must have. At least a major bug at this point :)

lauriii’s picture

Status: Needs review » Fixed

Slightly tweaked how source language is presented in the dashboard to make it more clear that it's different from translations. Otherwise this looks good so went ahead and merged. Thank you!

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.