06 · Language-neutral content ("und") counts as a template language – Summit is installed in "und" and every page fails¶
| Project | Drupal CMS (drupal_cms_installer) |
| Component | Installer |
| Category | Bug report |
| Priority | Critical |
| Status | Reported upstream as #3591482 |
Problem/Motivation¶
SiteTemplate::getLangcodesFromContent() collects the default_langcode of all default content, including und (not specified) from language-neutral content. Summit ships 53 entities in en and 3 in und. With two "languages" the template is considered multilingual, and detectDefaultLangcode() takes the first match (und) as default language. Because the language chosen in the installer is not among [en, und], the site is set up with system.site:default_langcode: und (and config_language_lock.locked_langcode: und).
The Event Horizon theme then fails on every page:
ValueError: NumberFormatter::__construct(): Argument #1 ($locale) "und" is invalid
In English this goes unnoticed, because en is among the detected languages.
Steps to reproduce¶
- Install Drupal CMS 2.2 in German (or any language other than English).
- Choose the Summit site template.
- Every page returns 500 (NumberFormatter error);
drush cget system.site default_langcodeshowsund.
Proposed resolution¶
Ignore und (LanguageInterface::LANGCODE_NOT_SPECIFIED) and zxx (LANGCODE_NOT_APPLICABLE) in both getLangcodesFromContent() and detectDefaultLangcode().
Remaining tasks¶
Patch + test.
Additional information¶
Workaround in the German Drupal CMS installer (patch_site_template_language_detection()). The Event Horizon theme should additionally not crash on an invalid locale (separate issue).
Copy to drupal.org
Issue title:
Language-neutral content ("und") counts as a template language – Summit is installed in "und" and every page fails
Issue summary (paste it into the "Issue summary" field; project, component, category and priority are in the table above):
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p><code>SiteTemplate::getLangcodesFromContent()</code> collects the <code>default_langcode</code> of all default content, including <code>und</code> (not specified) from language-neutral content. Summit ships 53 entities in <code>en</code> and 3 in <code>und</code>. With two "languages" the template is considered multilingual, and <code>detectDefaultLangcode()</code> takes the <strong>first</strong> match (<code>und</code>) as default language. Because the language chosen in the installer is not among <code>[en, und]</code>, the site is set up with <code>system.site:default_langcode: und</code> (and <code>config_language_lock.locked_langcode: und</code>).</p>
<p>The Event Horizon theme then fails on every page:</p>
<code>ValueError: NumberFormatter::__construct(): Argument #1 ($locale) "und" is invalid</code>
<p>In English this goes unnoticed, because <code>en</code> is among the detected languages.</p>
<h3 id="summary-steps-reproduce">Steps to reproduce</h3>
<ol>
<li>Install Drupal CMS 2.2 in German (or any language other than English).</li>
<li>Choose the Summit site template.</li>
<li>Every page returns 500 (NumberFormatter error); <code>drush cget system.site default_langcode</code> shows <code>und</code>.</li>
</ol>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Ignore <code>und</code> (<code>LanguageInterface::LANGCODE_NOT_SPECIFIED</code>) and <code>zxx</code> (<code>LANGCODE_NOT_APPLICABLE</code>) in both <code>getLangcodesFromContent()</code> and <code>detectDefaultLangcode()</code>.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>Patch + test.</p>
<h3>Additional information</h3>
<p>Workaround in the German Drupal CMS installer (<code>patch_site_template_language_detection()</code>). The Event Horizon theme should additionally not crash on an invalid locale (separate issue).</p>