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 +++++++++++++ src/Wallabag/CoreBundle/Resources/views/base.html.twig | 11 ++++++----- .../Resources/views/themes/baggy/Entry/entry.html.twig | 4 ++-- .../Resources/views/themes/material/Entry/entry.html.twig | 4 ++-- 4 files changed, 23 insertions(+), 9 deletions(-) (limited to 'src/Wallabag') 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 */ diff --git a/src/Wallabag/CoreBundle/Resources/views/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/base.html.twig index befe2ef2..496b3fb6 100644 --- a/src/Wallabag/CoreBundle/Resources/views/base.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/base.html.twig @@ -1,9 +1,10 @@ - - - - - +{% set lang = app.request.locale|default('') -%} + + + + + {% block head %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig index 4c0f85cc..c2e69a27 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig @@ -5,7 +5,7 @@ {% block content %}
-

{{ entry.title|e|default('entry.default_title'|trans)|raw }}

+

{{ entry.title|e|default('entry.default_title'|trans)|raw }}

@@ -96,7 +96,7 @@
-
+ {{ entry.content | raw }}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig index 70932f21..e23fa0e1 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig @@ -223,7 +223,7 @@ {% block content %}
-

{{ entry.title|striptags|default('entry.default_title'|trans)|raw }}

+

{{ entry.title|striptags|default('entry.default_title'|trans)|raw }}

-
+ {{ entry.content | raw }}
-- cgit v1.2.3