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.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | bootstrap_paragraphs-Tab-Accordion_Translation_Issue-2900377-13-8.x.patch | 3.59 KB | dunebl |
| #3 | bootstrap_paragraphs_tab_fix.patch | 1.39 KB | georgech |
Comments
Comment #2
georgech commentedComment #3
georgech commentedComment #4
georgech commentedComment #5
albertski commentedComment #6
georgech commentedComment #7
thejimbirch commentedI 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
Comment #8
albertski commented@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.
Comment #9
caspervoogt commentedI 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.
Comment #10
anruetherI ran into the same problem today. As soon as I create the second tab section, the error appears. The Backtrace starts with:
The patch file does not make any sense to me either.
Comment #11
caspervoogt commentedanruether, 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.
Comment #12
duneblComment #13
duneblI 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 specifiedIn 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.
Comment #14
thejimbirch commentedThanks 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.
Comment #16
thejimbirch commentedFixed in Dev