Use lang attribute

This commit is contained in:
Simounet
2019-01-11 21:09:49 +01:00
parent 7937ed0c20
commit 416d44d0ae
5 changed files with 51 additions and 9 deletions

View File

@ -787,6 +787,19 @@ class Entry
return $this->language;
}
/**
* Format the entry language to a valid html lang attribute.
*/
public function getHTMLLanguage()
{
$parsedLocale = \Locale::parseLocale($this->getLanguage());
$lang = '';
$lang .= $parsedLocale['language'] ?? '';
$lang .= isset($parsedLocale['region']) ? '-' . $parsedLocale['region'] : '';
return $lang;
}
/**
* @return string|null
*/