diff --git a/i2p2www/__init__.py b/i2p2www/__init__.py index beccae24..ba4d228b 100644 --- a/i2p2www/__init__.py +++ b/i2p2www/__init__.py @@ -192,6 +192,22 @@ def utility_processor(): else: return url_for('site_show', lang=lang) + # Shorthand for getting a language-specific url + def get_url_with_lang(endpoint, **args): + lang = 'en' + if hasattr(g, 'lang') and g.lang: + lang = g.lang + return url_for(endpoint, lang=lang, **args) + + # Get a specific language flag, or the flag for the current language + def get_flag(lang=None): + if not lang: + if hasattr(g, 'lang') and g.lang: + lang = g.lang + else: + lang = 'en' + return url_for('static', filename='images/flags/'+lang+'.png') + # Provide the canonical link to the current page def get_canonical_link(): protocol = request.url.split('//')[0] @@ -235,6 +251,8 @@ def utility_processor(): url_for_other_page=url_for_other_page, change_theme=change_theme, site_url=get_site_url, + get_url=get_url_with_lang, + get_flag=get_flag, canonical=get_canonical_link) diff --git a/i2p2www/pages/global/nav.html b/i2p2www/pages/global/nav.html index 31b58380..eea2bed0 100644 --- a/i2p2www/pages/global/nav.html +++ b/i2p2www/pages/global/nav.html @@ -2,11 +2,11 @@