- Issue created by @ramesh.tellamekala
- Assigned to shubham_jain
- Issue was unassigned.
- 🇮🇳India shubham_jain
Hi @ramesh.tellamekala, I followed your steps in Drupal 9.5.10 using php 8.1 but was unable to reproduce the error.
See attched screenshot for refrence. - 🇮🇳India ramesh.tellamekala
This error is thrown under the following circumstances in a multilingual site:
- Site have content translation, moderation enabled.
- User creates a node and sets the language to German.
- User updates the node and set the language to English.
- 🇮🇳India shubham_jain
Hi @ramesh.tellamekala, the screenshots that I shared are of the same node. let me explain you in detail what did I do.
Firstly as you said enabled Content Translation and Content moderation module.
Added German language because English was default.
Enabled ‘Show language selector on create and edit pages’ and ‘Enable translation’ options in article content type ‘Language Settings’.
The ‘Language’ field was visible in ‘Manage form display’ tab of article content type.
Created new field with entity reference version and selected accordian paragraph type.
Created a new article node with selection of ‘German’ in Language field
Edited the same article node and try to select ‘English’ language in ‘Language’ field and saved that node.No Error occoured.
Please correct me if I forgot something.
- last update
almost 2 years ago 29,462 pass, 1 fail - last update
almost 2 years ago 29,462 pass, 1 fail - Status changed to Needs review
almost 2 years ago 11:10am 13 September 2023 - Status changed to Needs work
almost 2 years ago 4:11pm 13 September 2023 - 🇺🇸United States smustgrave
Have not reviewed.
As a bug will need a test case showing the issue. Updated remaining tasks
Also proposed solution sounds like more "expected results" but not mentioning how the solution will be achieved.
- 🇨🇳China eason xu
1: Upload an image in media.
2: Reference this image in a paragraph.
3: Reference this paragraph to a node.
4: Access the usage list of image.
Result: Report an error. InvalidArgumentException: Invalid translation language (en) specified. in Drupal\Core\Entity\ContentEntityBase->getTranslation() (line 874 of /mnt/www/html/terumo01live/docroot/core/lib/Drupal/Core/Entity/ContentEntityBase.php).
This patch helped me solve this error. - 🇪🇸Spain rcodina Barcelona
Patch on #6 fixes the error for me on Drupal 10.1.6.
- First commit to issue fork.
- 🇻🇳Vietnam phannphong Ho Chi Minh City
I faced exactly the issue here and the patch #6 fixes the error on Drupal 10.1.6.
- 🇨🇭Switzerland handkerchief
Same issue, same solution, patch #6 works for me for Drupal 10.2.2.
- 🇮🇳India pooja saraah Chennai
Added Condition for Active Language Check:
The elseif condition checks if there is no translation object for the switched language used by the language field in the entity ($this->activeLangcode) and if the requested language ($langcode) is different.
If this condition is met, it initializes the translation using the default active translation.
Attached modified patch. - last update
over 1 year ago Composer error. Unable to continue. - 🇬🇷Greece bserem
None of the provided patches work for me. In my case I am trying to add translations to blocks using Drupal 10.2
- 🇷🇸Serbia levmyshkin Novi Sad, Serbia
I also had the problem with blocks translation, but this helped me #2137815:
https://www.drupal.org/project/drupal/issues/2137815 🐛 InvalidArgumentException: Invalid translation language specified. Needs work - last update
about 1 year ago Custom Commands Failed - 🇺🇸United States apmsooner
#6 makes my patch for image/file translations work for the AI translate module as mentioned here: https://www.drupal.org/project/ai/issues/3531717#comment-16168671 ✨ Add text extractor plugins for image and link field types Active
- First commit to issue fork.
- 🇺🇸United States nicxvan
I got this when turning on auto saving translations in tmgmt.
Drupal core tests do not run with patches anymore, if you see an older issue please create an MR from it so that tests can run and collaboration can happen more easily.
This still needs tests and a full review, but testing this with tmgmt it works.
- First commit to issue fork.
- 🇮🇳India immaculatexavier
Hi all,
I've added a functional test to cover the scenario mentioned in this issue. The test checks that when a user creates an article node in German and then switches the language to English using the language selector on the edit form, it saves without any errors.
This covers the exact steps described in the issue and ensures the language switch functionality works as expected. Happy to make adjustments if needed.
Thanks!
- 🇺🇸United States smustgrave
Do we not have an existing test we can expand vs adding a brand new one
- 🇮🇳India immaculatexavier
Hi,
Now added the test case testSwitchLangcodeWithoutExistingTranslation() to the existing ContentTranslationLanguageChangeTest class. This expands the current test coverage instead of creating a new test class, aligning with the feedback to reuse existing tests where possible. The test validates the fallback logic when switching the langcode on a node that doesn't yet have a translation.
Kindly let me know if any further adjustments are needed.
- 🇺🇸United States apmsooner
The patch applies clean for 10.5.1. I followed the steps and it works without error. Additionally, combined with patch for AI translate module ( https://www.drupal.org/project/ai/issues/3531717 ✨ Add text extractor plugins for image and link field types Active ) and following the steps outlined there, all translatable properties on image/file fields get translated as the the batch process is allowed to finish due to this core fix.
- 🇺🇸United States nicxvan
This still needs work.
There are other tests failing.
We also have to confirm this is the appropriate solution.
- 🇺🇸United States apmsooner
FYI, The errors are on a different test and seem to be related to this line from what i can tell: https://git.drupalcode.org/issue/drupal-3386915/-/blob/3386915-Fix-savin...
- 🇺🇸United States nicxvan
Yep exactly, which means that we may be breaking something else.
Let me preface this by saying I'm about to drop a bunch of questions I ask myself when reviewing issues.
I recognize it is a lot, but adding these to your own process can help prevent things from being knocked back and increase the chances of issues being fixed quicker.Here is a list of questions that core committers ask before committing and they are good to keep in mind when reviewing.
https://www.drupal.org/about/core/policies/maintainers/commit-guide#prec... →If you read further up:
You don't have to know everything! :)
So don't worry if you can't answer every last one yourself.
In addition to that before marking something RTBC here are some things I check myself, not in a particular order.
- Have I reviewed the code (sometimes including surrounding code) enough to understand what is changing
- Are all tests passing. (This will prevent marking when there are known issues like here)
- Is there a test written for this issue specifically (not all issues need tests, but almost all do)
- Does the test only job fail (there is a special test that runs just the test and not the fix to confirm it will help prevent regressions)
- Are there more edge cases that are missing a fix
- Are there follow up issues mentioned in comments or code that should be created
- Does this need comments explaining what is happening
- Have other user's comments on the MR or in the issue been adequately addressed and answered
- Does this need a Change Record