InvalidArgumentException: Invalid translation language (en) specified

Created on 13 September 2023, about 1 year ago
Updated 26 March 2024, 8 months ago

Problem/Motivation

This error occurred when we enabled language field in content types and switching languages in node edit by using language field (node/2/edit):

InvalidArgumentException: Invalid translation language (en) specified. in Drupal\Core\Entity\ContentEntityBase->getTranslation() (line 870 of /app/docroot/core/lib/Drupal/Core/Entity/ContentEntityBase.php).

Steps to reproduce

  1. Install using standard profile in English
  2. Log in as admin user
  3. Enable Content Translation module
  4. Enable Content moderation module
  5. Add English, German language
  6. Enable ‘Show language selector on create and edit pages’ and ‘Enable translation’ options in article content type ‘Language Settings’
  7. Enable ‘Language’ field in article content type from ‘Manage form display’ tab
  8. Create new field with entity reference and select any of the paragraph
  9. Create a new article node with selection of ‘German’ in Language field
  10. Edit recent article node and try to select ‘English’ language in ‘Language’ field and try to save that node
  11. You will get a fatal error

Proposed resolution

Article node should be save with English language without any fatal error.

Remaining tasks

Add test coverage

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Language module 

Last updated 29 days ago

  • Maintained by
  • 🇩🇪Germany @sun
Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024