Having trouble loading a translation for a paragraph


I’m working with the TMGMT module to pull in translated content for my site. We’re in the review stage and I’m having some issues generating previews for some of my pages.

All translated content shows correctly in the previews except for some paragraph-based components that have some custom-built modules doing some preprocess work. I’ve confirmed that these paragraphs were translated.

I suspect that the issue comes from the paragraphs being nested. The parent paragraph in these preprocessed functions shows up translated but any that are preprocessed and nested show up in the site’s default language.

I’ve attempted to use:


but this doesn’t work and returns an error that the language code couldn’t be found. I assume because the translation exists but is still in a review state.

So I tried mimicking what TMGMT does for entities in the preview controller by initializing the translation first:

if (!$paragraph->hasTranslation($langcode)) { $paragraph->addTranslation($langcode, $paragraph->toArray()); } 

Still no success. Any suggestions on how to load these translations?

submitted by /u/Certhio
[visit reddit] [comments]

قالب وردپرس