- Issue created by @zilloww
- 🇨🇭Switzerland zilloww
I fixed this issue by noticing that in the config/install folder of the module, there is a eu_cookie_compliance.settings.yml file that contains the key 'langcode' defaulted to 'en'. Since I don't have English language on my website, Drupal doesn't recognize the langcode 'en'. That's the source of the error.
To fix this:
- Go to your drupal/config/sync
- Open the file "eu_cookie_compliance.settings.yml"
- Add the "langcode: xx" (replace 'xx' by whatever is your default website language for example "langcode: fr"
- drush cim
- Clear cache
- The issue should be fixed
- Status changed to Needs review
11 months ago 7:47am 7 February 2024 - Status changed to Active
24 days ago 12:08pm 24 November 2024 - 🇳🇴Norway svenryen
Hi!
Thanks for the report, I was able to reproduce.
For the record, here are the exact steps:
- I installed Drupal 10.1.4 (most likely the specific version isn't needed in order to reproduce the bug) using "drush site:install"
- I installed EU Cookie Compliance, causing the module to have English settings.
- Then I installed Configuration Translation, Content Translation, Interface Translation and Language (note that we might not need all of them)
- I added French and Norwegian languages, setting French as default
- I removed the English language (this is what causes the bug to appear)
- Then I configured the site to have Norwegian as the main language, French as available for translation
- I navigated to
nb/admin/config/system/eu-cookie-compliance/settings/translate
Result:
TypeError: Drupal\config_translation\FormElement\ListElement::getTranslationBuild(): Argument #1 ($source_language) must be of type Drupal\Core\Language\LanguageInterface, null given, called in /var/www/html/web/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php on line 178 in Drupal\config_translation\FormElement\ListElement->getTranslationBuild() (line 48 of core/modules/config_translation/src/FormElement/ListElement.php). Drupal\config_translation\Form\ConfigTranslationFormBase->buildForm(Array, Object, Object, 'eu_cookie_compliance.settings', 'en') (Line: 26) Drupal\config_translation\Form\ConfigTranslationAddForm->buildForm(Array, Object, Object, 'eu_cookie_compliance.settings', 'fr')
Note: Please leave the Issue Status as "Active" unless there's code to review in the issue as a gitlab branch or a patch file.
- 🇳🇴Norway svenryen
I checked, and I can reproduce in Drupal 11.0.9/PHP 8.3.12.
I'm not sure what we can do in the module, as we're not in control of the translation system.I'll see if there's a core issue for this bug, otherwise I'll create an issue in the Drupal core project.
- 🇳🇴Norway svenryen
I found this issue in the core issue queue, which seems related.
https://www.drupal.org/project/drupal/issues/3184569 🐛 Can't translate config when source language does not exists Needs work
Please post any follow-up discussion there. There's nothing we can do in this module.
- 🇳🇴Norway svenryen
The patch in the Drupal core issue ( https://www.drupal.org/files/issues/2023-02-06/3184569_14.patch → ) solves the bug.
If anybody wants to write a test for the core fix, it could perhaps be committed.