From 1ebddc5185f819def2ba5c2ccfd994307ec6b264 Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Sun, 5 Feb 2012 00:14:11 -0800 Subject: [PATCH] Add _md template util for translation of complex text. Added whitespace disabling wrapping around md with wrap=False -- this should have been in the original commit that added the wrap argument. --- r2/r2/lib/filters.py | 2 +- r2/r2/templates/oauth2authorization.html | 6 +++--- r2/r2/templates/utils.html | 8 ++++++-- r2/setup.cfg | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/r2/r2/lib/filters.py b/r2/r2/lib/filters.py index a8237ec22..7dce89b9c 100644 --- a/r2/r2/lib/filters.py +++ b/r2/r2/lib/filters.py @@ -226,7 +226,7 @@ def safemarkdown(text, nofollow=False, wrap=True, **kwargs): if wrap: return SC_OFF + MD_START + text + MD_END + SC_ON else: - return text + return SC_OFF + text + SC_ON def keep_space(text): diff --git a/r2/r2/templates/oauth2authorization.html b/r2/r2/templates/oauth2authorization.html index 950602156..ba172fdc5 100644 --- a/r2/r2/templates/oauth2authorization.html +++ b/r2/r2/templates/oauth2authorization.html @@ -21,12 +21,12 @@ ################################################################################ <%! from r2.lib.template_helpers import static, s3_https_if_secure - from r2.lib.filters import safemarkdown %> +<%namespace file="utils.html" import="_md" />
${thing.client.name} icon - ${unsafe(safemarkdown(_("#[%(app_name)s](%(app_about_url)s) requests to connect with your reddit account.") - % dict(app_name=thing.client.name, app_about_url=thing.client.about_url), wrap=False))} + ${_md("#[%(app_name)s](%(app_about_url)s) requests to connect with your reddit account." + % dict(app_name=thing.client.name, app_about_url=thing.client.about_url))}

${_("Allow %(app_name)s to:") % dict(app_name=thing.client.name)}

    diff --git a/r2/r2/templates/utils.html b/r2/r2/templates/utils.html index 68c3ba04e..530c6dd80 100755 --- a/r2/r2/templates/utils.html +++ b/r2/r2/templates/utils.html @@ -23,7 +23,7 @@ <%! import json from r2.models import FakeSubreddit - from r2.lib.filters import spaceCompress, unsafe + from r2.lib.filters import spaceCompress, unsafe, safemarkdown from r2.lib.template_helpers import add_sr, js_config, static from r2.lib.utils import cols, long_datetime, timesince from r2.lib.tracking import UserInfo @@ -561,4 +561,8 @@ ${unsafe(txt)} %elif thing.editted: * %endif - \ No newline at end of file + + +<%def name="_md(text, wrap=False)"> + ${unsafe(safemarkdown(_(text), wrap=wrap))} + diff --git a/r2/setup.cfg b/r2/setup.cfg index c6e354839..8fe44d8a8 100644 --- a/r2/setup.cfg +++ b/r2/setup.cfg @@ -35,6 +35,6 @@ make-dirs=1 [extract_messages] add_comments = TRANSLATORS: -keywords = P_:1,2 +keywords = P_:1,2 _md mapping_file = babel.cfg width = 80