Skip to content
This repository
Browse code

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.
  • Loading branch information...
commit 1ebddc5185f819def2ba5c2ccfd994307ec6b264 1 parent e28541d
Max Goodman chromakode authored
2  r2/r2/lib/filters.py
@@ -226,7 +226,7 @@ def safemarkdown(text, nofollow=False, wrap=True, **kwargs):
226 226 if wrap:
227 227 return SC_OFF + MD_START + text + MD_END + SC_ON
228 228 else:
229   - return text
  229 + return SC_OFF + text + SC_ON
230 230
231 231
232 232 def keep_space(text):
6 r2/r2/templates/oauth2authorization.html
@@ -21,12 +21,12 @@
21 21 ################################################################################
22 22 <%!
23 23 from r2.lib.template_helpers import static, s3_https_if_secure
24   - from r2.lib.filters import safemarkdown
25 24 %>
  25 +<%namespace file="utils.html" import="_md" />
26 26 <div class="content oauth2-authorize">
27 27 <img class="icon" src="${s3_https_if_secure(thing.client.icon_url)}" alt="${thing.client.name} icon" />
28   - ${unsafe(safemarkdown(_("#[%(app_name)s](%(app_about_url)s) requests to connect with your reddit account.")
29   - % dict(app_name=thing.client.name, app_about_url=thing.client.about_url), wrap=False))}
  28 + ${_md("#[%(app_name)s](%(app_about_url)s) requests to connect with your reddit account."
  29 + % dict(app_name=thing.client.name, app_about_url=thing.client.about_url))}
30 30 <div class="access">
31 31 <h2>${_("Allow %(app_name)s to:") % dict(app_name=thing.client.name)}</h2>
32 32 <ul>
8 r2/r2/templates/utils.html
@@ -23,7 +23,7 @@
23 23 <%!
24 24 import json
25 25 from r2.models import FakeSubreddit
26   - from r2.lib.filters import spaceCompress, unsafe
  26 + from r2.lib.filters import spaceCompress, unsafe, safemarkdown
27 27 from r2.lib.template_helpers import add_sr, js_config, static
28 28 from r2.lib.utils import cols, long_datetime, timesince
29 29 from r2.lib.tracking import UserInfo
@@ -561,4 +561,8 @@
561 561 %elif thing.editted:
562 562 <em>*</em>
563 563 %endif
564   -</%def>
  564 +</%def>
  565 +
  566 +<%def name="_md(text, wrap=False)">
  567 + ${unsafe(safemarkdown(_(text), wrap=wrap))}
  568 +</%def>
2  r2/setup.cfg
@@ -35,6 +35,6 @@ make-dirs=1
35 35
36 36 [extract_messages]
37 37 add_comments = TRANSLATORS:
38   -keywords = P_:1,2
  38 +keywords = P_:1,2 _md
39 39 mapping_file = babel.cfg
40 40 width = 80

0 comments on commit 1ebddc5

Please sign in to comment.
Something went wrong with that request. Please try again.