Cool module, thanks! 🎉

I see the entity is marked as translatable, but I'm not seeing any way to translate it from the UI. Am I missing something or is that just not implemented yet?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

justafish created an issue. See original summary.

larowlan’s picture

Category: Support request » Bug report

Most likely a bug.
To be honest, translation is not my strong suite.
I thought I added the required annotations to make this work, but without a use-case, hadn't tested it.

Will try and carve out some time to dig into it.

larowlan’s picture

Ah! it looks like content translation module only provides UI for entities that have a canonical route - which we don't.

So should just be a matter of adding them in.

larowlan’s picture

Issue tags: +Needs tests
FileSize
2.32 KB

Give this a shot

larowlan’s picture

Note to self:\Drupal\Tests\node\Functional\NodeTranslationUITest should provide a good guide for an equivalent test for this

justafish’s picture

Thanks @larowlan! I applied the patch and enabled translation for Microcontent at /admin/config/regional/content-language, and now I get the option to translate the microcontent. However clicking it throws up this error

/admin/content/microcontent/1/translations

Drupal\Core\Entity\Exception\UndefinedLinkTemplateException: No link template 'canonical' found for the 'microcontent' entity type in Drupal\Core\Entity\EntityBase->toUrl() (line 227 of core/lib/Drupal/Core/Entity/EntityBase.php).
Drupal\content_translation\Controller\ContentTranslationController->overview(Object, 'microcontent') (Line: 17)
Drupal\tmgmt_content\Controller\ContentTranslationControllerOverride->overview(Object, 'microcontent')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 694)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
larowlan’s picture

So content translation really wants the entity type to have a canonical URI.

Let me see what I can work out.

larowlan’s picture

Status: Active » Needs review
FileSize
589 bytes

It looks like block content just duplicates its edit form for the sake of a canonical route
Feels like a hack, but looks like tmgmt_content module can't handle the above patch so maybe shouldn't fight it.

Does this help?

deviantintegral’s picture

Adding the canonical link looks to have fixed this for me - at least, I can now enable translations for a field.

deviantintegral’s picture

Actually, this seems to break editing microcontent entities. Instead of rendering the edit form, the entity is rendered instead.

larowlan’s picture

ok, will wrangle that a bit later today

larowlan’s picture

FileSize
1.53 KB

Perhaps this?

deviantintegral’s picture

FileSize
1.56 KB

I was still getting exceptions when trying to load the canonical route. I think this is probably a core bug since returning FALSE / NULL matches the API, but instead I did what media module does.

larowlan’s picture

Thanks, this looks good to me, just needs a test, will see if I can knock something out this week

slv_’s picture

FileSize
4.91 KB

Re-rolling patch, adding KernelTest that verifies translation is handled by the default Core class, and that translations are stored as expected, with the proper per-translation values, etc.

  • larowlan committed b8b5c1c on 8.x-1.x authored by slv_
    Issue #3128293 by larowlan, deviantintegral, slv_, justafish:...
larowlan’s picture

Status: Needs review » Fixed

Fixed, cutting 8.x-1.0-alpha8

Thanks all

Status: Fixed » Closed (fixed)

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