]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Entry.php
Use lang attribute
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Entry.php
index beda581af2ee214abb96c11a6fd48eb6af30908b..190457983f92eb9d5bc77a25c24b08646ddb918f 100644 (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
      */