Set <html> lang attr for current language, set dir="rtl" attr for RTL languages
This commit is contained in:
@ -73,6 +73,10 @@ SUPPORTED_LANG_NAMES = {
|
|||||||
'uk': u'Ukrainian',
|
'uk': u'Ukrainian',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RTL_LANGS = [
|
||||||
|
'he',
|
||||||
|
]
|
||||||
|
|
||||||
DEFAULT_GETTEXT_DOMAIN = 'priority'
|
DEFAULT_GETTEXT_DOMAIN = 'priority'
|
||||||
GETTEXT_DOMAIN_MAPPING = {
|
GETTEXT_DOMAIN_MAPPING = {
|
||||||
'about': ['about'],
|
'about': ['about'],
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{%- from "global/macros" import change_lang with context -%}
|
{%- from "global/macros" import change_lang with context -%}
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="{{ g.lang }}"{% if is_rtl(g.lang) %} dir="rtl"{% endif %}>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>{% block title_outer %}{% block title %}{% endblock %} - I2P{% endblock %}</title>
|
<title>{% block title_outer %}{% block title %}{% endblock %} - I2P{% endblock %}</title>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from flask import g, request, safe_join, url_for
|
from flask import g, request, safe_join, url_for
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
from i2p2www import CANONICAL_DOMAIN, CURRENT_I2P_VERSION, SUPPORTED_LANGS, SUPPORTED_LANG_NAMES, STATIC_DIR, app
|
from i2p2www import CANONICAL_DOMAIN, CURRENT_I2P_VERSION, RTL_LANGS, SUPPORTED_LANGS, SUPPORTED_LANG_NAMES, STATIC_DIR, app
|
||||||
|
|
||||||
INPROXY = '.us'
|
INPROXY = '.us'
|
||||||
|
|
||||||
@ -35,6 +35,14 @@ def utility_processor():
|
|||||||
lang = g.lang
|
lang = g.lang
|
||||||
return url_for(endpoint, lang=lang, **args)
|
return url_for(endpoint, lang=lang, **args)
|
||||||
|
|
||||||
|
def is_rtl_lang(lang=None):
|
||||||
|
if not lang:
|
||||||
|
if hasattr(g, 'lang') and g.lang:
|
||||||
|
lang = g.lang
|
||||||
|
else:
|
||||||
|
lang = 'en'
|
||||||
|
return lang in RTL_LANGS
|
||||||
|
|
||||||
# Get a specific language flag, or the flag for the current language
|
# Get a specific language flag, or the flag for the current language
|
||||||
def get_flag(lang=None):
|
def get_flag(lang=None):
|
||||||
if not lang:
|
if not lang:
|
||||||
@ -102,6 +110,7 @@ def utility_processor():
|
|||||||
logo_url=get_logo_for_theme,
|
logo_url=get_logo_for_theme,
|
||||||
site_url=get_site_url,
|
site_url=get_site_url,
|
||||||
get_url=get_url_with_lang,
|
get_url=get_url_with_lang,
|
||||||
|
is_rtl=is_rtl_lang,
|
||||||
get_flag=get_flag,
|
get_flag=get_flag,
|
||||||
ver=get_current_version,
|
ver=get_current_version,
|
||||||
canonical=get_canonical_link,
|
canonical=get_canonical_link,
|
||||||
|
Reference in New Issue
Block a user