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.
This commit is contained in:
Max Goodman
2012-02-05 00:14:11 -08:00
parent e28541d488
commit 1ebddc5185
4 changed files with 11 additions and 7 deletions

View File

@@ -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):

View File

@@ -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" />
<div class="content oauth2-authorize">
<img class="icon" src="${s3_https_if_secure(thing.client.icon_url)}" alt="${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))}
<div class="access">
<h2>${_("Allow %(app_name)s to:") % dict(app_name=thing.client.name)}</h2>
<ul>

View File

@@ -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:
<em>*</em>
%endif
</%def>
</%def>
<%def name="_md(text, wrap=False)">
${unsafe(safemarkdown(_(text), wrap=wrap))}
</%def>

View File

@@ -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