Merge pull request #984 from joachimesque/a11y-html-lang

Accessibility: add language to `lang` attr on `html` tag
This commit is contained in:
Mouse Reeve 2021-04-22 13:29:22 -07:00 committed by GitHub
commit e546b1b1ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -1,7 +1,7 @@
{% load bookwyrm_tags %} {% load bookwyrm_tags %}
{% load i18n %} {% load i18n %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="{% get_lang %}">
<head> <head>
<title>{% block title %}BookWyrm{% endblock %} | {{ site.name }}</title> <title>{% block title %}BookWyrm{% endblock %} | {{ site.name }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">

View file

@ -1,7 +1,7 @@
""" template filters """ """ template filters """
from uuid import uuid4 from uuid import uuid4
from django import template from django import template, utils
from django.db.models import Avg from django.db.models import Avg
from bookwyrm import models, views from bookwyrm import models, views
@ -217,3 +217,10 @@ def active_read_through(book, user):
def comparison_bool(str1, str2): def comparison_bool(str1, str2):
""" idk why I need to write a tag for this, it reutrns a bool """ """ idk why I need to write a tag for this, it reutrns a bool """
return str1 == str2 return str1 == str2
@register.simple_tag(takes_context=False)
def get_lang():
""" get current language, strip to the first two letters """
language = utils.translation.get_language()
return language[0 : language.find("-")]