Problem/Motivation
When getTranslation is called with the langcode of an invalid language, it throws an exception.
InvalidArgumentException: Unable to get translation for the invalid language 'de'. in Drupal\Core\Entity\EntityNG->getTranslation() (line 230 of /Users/clark/Sites/d8jsonld/core/lib/Drupal/Core/Entity/EntityNG.php).
However, when an entity's default language is set to an invalid language, it does not throw an exception. It simply makes calls to $entity->language() return FALSE.
Proposed resolution
Throw an exception when an entity's default language is set to an invalid language.
Comments
Comment #1
plachComment #2
plachSorry, misread the IS
Comment #3
plachComment #16
pameeela CreditAttribution: pameeela at Technocrat commentedNot sure how to reproduce. I tried these steps:
/node/{nid}
Perhaps this was fixed elsewhere or maybe just need to know how to reproduce.
Comment #17
quietone CreditAttribution: quietone at PreviousNext commentedReading the getTranslation function this is still true. That method, which is public, does not check if the language code is a valid one. Perhaps it should.
Comment #19
quietone CreditAttribution: quietone at PreviousNext commented@linclark, Thank you for reporting this problem. We rely on issue reports like this one to resolve bugs and improve Drupal core.
There has been no confirmation that this still exists in the past 10 years. More information about this issue was asked for in 1 years ago and none has been provided. Therefor closing.
If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").
Thanks!