We found the following issue with bootstrap paragraphs:

A basic page has a tab bootstrap paragraph type with i.e. a simple paragraph within its tab section. When this page was translated to another language besides the default one we were getting a 500 Error on the translated view node page.

InvalidArgumentException: Invalid translation language (el) specified. in Drupal\Core\Entity\ContentEntityBase->getTranslation()

This error appears when there are more than 1 tab sections or accordion sections etc.

It also appeared in case of 1 single tab section and 1 single accordion section.

Comments

georgech created an issue. See original summary.

georgech’s picture

StatusFileSize
new1.6 KB
georgech’s picture

StatusFileSize
new1.39 KB
georgech’s picture

albertski’s picture

Status: Fixed » Needs review
georgech’s picture

Issue summary: View changes
thejimbirch’s picture

I reached out to @Mikechr and @phanosd to see if they can review.

They helped with the first translation issue we had:
https://www.drupal.org/node/2877896

albertski’s picture

Status: Needs review » Needs work

@georgech Thanks for the patch. There seems to be an issue with the patch file. I can't apply the patch. You may want to refer to Making a Drupal patch with Git.

caspervoogt’s picture

I have had a look at the patch files here and can't make sense of any of them; I was trying to re-roll it, but no dice.

anruether’s picture

I ran into the same problem today. As soon as I create the second tab section, the error appears. The Backtrace starts with:

Auf der Website ist ein unvorhergesehener Fehler aufgetreten. Bitte versuchen Sie es später nochmal.</br></br><em class="placeholder">InvalidArgumentException</em>: Invalid translation language (de) specified. in <em class="placeholder">Drupal\Core\Entity\ContentEntityBase-&gt;getTranslation()</em> (line <em class="placeholder">866</em> of <em class="placeholder">core/lib/Drupal/Core/Entity/ContentEntityBase.php</em>). <pre class="backtrace">Twig_Template-&gt;getAttribute(Object, &#039;getTranslation&#039;, Array, &#039;method&#039;) (Line: 262)
__TwigTemplate_19ab9580759be1a85aab482cdd4b7e6519790d43631c6f8456583f3b702e50e7-&gt;doDisplay(Array, Array) (Line: 432)
Twig_Template-&gt;displayWithErrorHandling(Array, Array) (Line: 403)
Twig_Template-&gt;display(Array) (Line: 411)
Twig_Template-&gt;render(Array) (Line: 64)
twig_render_template(&#039;modules/contrib/bootstrap_paragraphs/templates/paragraph--bp-tabs.html.twig&#039;, Array) (Line: 384)
...

The patch file does not make any sense to me either.

caspervoogt’s picture

anruether, what worked for me was to use Paragraphs 8.1.x-dev with this patch 242 from https://www.drupal.org/project/paragraphs/issues/2461695#comment-12444656 . Be careful with that, because it changes how translations work, and may impact existing nodes; I noticed that my existing translations would still show on the page but when I edited it would not be there.. it would show the source translation for that paragraph instead. That was easily solved by removing those paragraphs from the translated node and re-adding them. For new nodes it's fine.

dunebl’s picture

Title: Tab Bootstrap Paragraph Type Translation Issue » Tab/Accordion Bootstrap Paragraph Type Translation Issue: Invalid translation language specified
dunebl’s picture

Status: Needs work » Needs review
StatusFileSize
new3.59 KB

I think I could catch the origin of this bug: in some case, a tab section (or accordion section) doesn't have a translation (other sections may have a translation, but not this one).
In this case, the call entity.getTranslation(lang) in the twig template return an exception as it is specified in ContentEntityInterface::getTranslation() should throw an exception when an invalid language is specified
In the attached patch, I have added a if condition to check if the translation exists... if not, the twig is using the source/original entity.

thejimbirch’s picture

Thanks so much @DuneBL. This patch applies perfectly and does not effect non-translated sites. I will need help testing on translated sites after it is live. I will push to dev in a minute.

  • DuneBL authored c4a5432 on 8.x-2.x
    Issue #2900377 by DuneBL, albertski, thejimbirch, caspervoogt: Tab/...
thejimbirch’s picture

Status: Needs review » Fixed

Fixed in Dev

Status: Fixed » Closed (fixed)

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