Issue #2994000 by Lendude, Pasqualle, quietone, pameeela: Notice in logs when setting invalid translation config for a content type

merge-requests/2501/head
catch 2022-07-10 13:20:37 +09:00
parent 54ee1df219
commit da9a2b407a
2 changed files with 12 additions and 1 deletions

View File

@ -619,7 +619,7 @@ function content_translation_language_configuration_element_validate($element, F
$values = $form_state->getValue($key);
if (!$values['language_alterable'] && $values['content_translation'] && \Drupal::languageManager()->isLanguageLocked($values['langcode'])) {
foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_LOCKED) as $language) {
$locked_languages[] = $language->getName();
$locked_languages[$language->getId()] = $language->getName();
}
// @todo Set the correct form element name as soon as the element parents
// are correctly set. We should be using NestedArray::getValue() but for

View File

@ -204,6 +204,17 @@ class ContentTranslationSettingsTest extends BrowserTestBase {
$this->assertEquals($definitions['body']->isTranslatable(), $field->isTranslatable(), 'Configurable field translatability correctly switched.');
}
// Test that we can't use the 'Not specified' default language when it is
// not showing in the language selector.
$edit = [
'language_configuration[langcode]' => 'und',
'language_configuration[language_alterable]' => FALSE,
'language_configuration[content_translation]' => TRUE,
];
$this->drupalGet('admin/structure/types/manage/article');
$this->submitForm($edit, 'Save content type');
$this->getSession()->getPage()->hasContent('"Show language selector" is not compatible with translating content that has default language: und. Either do not hide the language selector or pick a specific language.');
// Test that the order of the language list is similar to other language
// lists, such as in Views UI.
$this->drupalGet('admin/config/regional/content-language');