I would like to change a node’s html ‘lang’ from site’s default to the selected language when creating a node.
For example, if I create a node and while creating I select French as the language, I would like the page’s html ‘lang’ to "fr"
So far I have this:
/** @var DrupalCoreTemplateAttribute $html_attribute */ $html_attribute = $variables['html_attributes']; $node->get('langcode')->value; if ($html_attribute->hasAttribute("lang")) { $html_attribute->removeAttribute('lang'); $html_attribute->setAttribute('lang', 'langcode'); }