From 416d44d0aef68b04aec90d207e33feb68706e1c3 Mon Sep 17 00:00:00 2001 From: Simounet Date: Fri, 11 Jan 2019 21:09:49 +0100 Subject: Use lang attribute --- src/Wallabag/CoreBundle/Entity/Entry.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/Wallabag/CoreBundle/Entity') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index beda581a..19045798 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -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 */ -- cgit v1.2.3