summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-10-05 15:03:28 +0200
committerAlexandre Flament <alex@al-f.net>2021-10-12 21:06:20 +0200
commit988910d451b4360209307ef2c3070fdb563d7c35 (patch)
tree969df0dbf26abefd52539c9e0e7699b2328e878f /searx
parent66b7be09656798b745f95ff0ce7669db014b3b38 (diff)
[fix] templates: lang attribute of html uses hyphen
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes#attr-lang https://www.w3.org/TR/REC-xml/#sec-lang-tag
Diffstat (limited to 'searx')
-rw-r--r--searx/templates/oscar/base.html2
-rw-r--r--searx/templates/simple/base.html2
-rwxr-xr-xsearx/webapp.py7
3 files changed, 9 insertions, 2 deletions
diff --git a/searx/templates/oscar/base.html b/searx/templates/oscar/base.html
index 01dedc782..de7d05bf6 100644
--- a/searx/templates/oscar/base.html
+++ b/searx/templates/oscar/base.html
@@ -1,6 +1,6 @@
{% from 'oscar/macros.html' import icon %}
<!DOCTYPE html>
-<html lang="{{ preferences.get_value('locale') }}" xml:lang="{{ preferences.get_value('locale') }}"{% if rtl %} dir="rtl"{% endif %} class="nojs">
+<html lang="{{ locale_rfc5646 }}" xml:lang="{{ locale_rfc5646 }}"{% if rtl %} dir="rtl"{% endif %} class="nojs">
<head>
<meta charset="UTF-8" />
<meta name="description" content="SearXNG - a privacy-respecting, hackable metasearch engine" />
diff --git a/searx/templates/simple/base.html b/searx/templates/simple/base.html
index ac6a09822..108d2fcf5 100644
--- a/searx/templates/simple/base.html
+++ b/searx/templates/simple/base.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html class="no-js" lang="en" {% if rtl %} dir="rtl"{% endif %}>
+<html class="no-js" lang="{{ locale_rfc5646 }}" {% if rtl %} dir="rtl"{% endif %}>
<head>
<meta charset="UTF-8" />
<meta name="description" content="SearXNG — a privacy-respecting, hackable metasearch engine">
diff --git a/searx/webapp.py b/searx/webapp.py
index 61992c99f..85eb003a7 100755
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -398,6 +398,11 @@ def _get_enable_categories(all_categories):
return [x for x in all_categories if x in enabled_categories]
+def get_locale_rfc5646(locale):
+ parts = locale.split('_')
+ return parts[0].lower() + '-' + parts[-1].upper()
+
+
def render(template_name, override_theme=None, **kwargs):
# values from the HTTP requests
kwargs['endpoint'] = 'results' if 'q' in kwargs else request.endpoint
@@ -420,6 +425,8 @@ def render(template_name, override_theme=None, **kwargs):
kwargs['translations'] = json.dumps(get_translations(), separators=(',', ':'))
locale = request.preferences.get_value('locale')
+ kwargs['locale_rfc5646'] = get_locale_rfc5646(locale)
+
if locale in RTL_LOCALES and 'rtl' not in kwargs:
kwargs['rtl'] = True
if 'current_language' not in kwargs: