X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FEntity%2FEntry.php;h=0e19a0c20afb25e7ed86e0fdd480a934d6ba4761;hb=8ee7b1603d23297a6c183105f79b1290ce9828bf;hp=beda581af2ee214abb96c11a6fd48eb6af30908b;hpb=8d4ed0df0633f43fc2d65fef72c36070113844d1;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index beda581a..0e19a0c2 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -552,7 +552,7 @@ class Entry * * @return Entry */ - public function setCreatedAt(\DateTime $createdAt) + public function setCreatedAt(\DateTimeInterface $createdAt) { $this->createdAt = $createdAt; @@ -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 */