Fixes #6182 -- Add html "lang" attribute.

This commit is contained in:
Buster Neece 2023-03-31 10:34:34 -05:00
parent f4cfb7c59d
commit 5464c0db6c
No known key found for this signature in database
GPG Key ID: F1D2E64A0005E80E
3 changed files with 12 additions and 3 deletions

View File

@ -61,6 +61,14 @@ enum SupportedLocales: string
return self::stripLocaleEncoding($this);
}
/**
* @return string The first two characters of the locale (for HTML `lang` attribute).
*/
public function getHtmlLang(): string
{
return strtolower(substr($this->value, 0, 2));
}
public function register(Environment $environment): void
{
// Skip translation file reading for default locale.

View File

@ -18,7 +18,7 @@ $title ??= null;
$header ??= null;
?>
<!DOCTYPE html>
<html data-theme="<?= $customization->getTheme()->value ?>">
<html lang="<?= $customization->getLocale()->getHtmlLang() ?>" data-theme="<?= $customization->getTheme()->value ?>">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

View File

@ -1,4 +1,3 @@
<!DOCTYPE html>
<?php
/**
* @var League\Plates\Template\Template $this
@ -16,7 +15,9 @@
$title ??= null;
$hide_footer ??= false;
?>
<html data-theme="<?= $customization->getPublicTheme()->value ?>">
<!DOCTYPE html>
<html lang="<?= $customization->getLocale()->getHtmlLang() ?>"
data-theme="<?= $customization->getPublicTheme()->value ?>">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">