Make unedited link taglines still translatable

In the process, move taglinetext logic to a python file
This commit is contained in:
Keith Mitchell
2012-05-16 11:14:24 -07:00
parent 7bc9df1148
commit 1a3e1dd2a6
2 changed files with 38 additions and 17 deletions

View File

@@ -528,6 +528,38 @@ class Link(Thing, Printable):
item.expunged = Link._should_expunge_selftext(item)
item.editted = getattr(item, "editted", False)
taglinetext = ''
if item.different_sr:
author_text = (" <span>" + _("by %(author)s to %(reddit)s") +
"</span>")
else:
author_text = " <span>" + _("by %(author)s") + "</span>"
if item.editted:
if item.score_fmt == Score.points:
taglinetext = ("<span>" +
_("%(score)s submitted %(when)s "
"ago%(lastedited)s") +
"</span>")
taglinetext += author_text
elif item.different_sr:
taglinetext = _("submitted %(when)s ago%(lastedited)s "
"by %(author)s to %(reddit)s")
else:
taglinetext = _("submitted %(when)s ago%(lastedited)s "
"by %(author)s")
else:
if item.score_fmt == Score.points:
taglinetext = ("<span>" +
_("%(score)s submitted %(when)s ago") +
"</span>")
taglinetext += author_text
elif item.different_sr:
taglinetext = _("submitted %(when)s ago by %(author)s "
"to %(reddit)s")
else:
taglinetext = _("submitted %(when)s ago by %(author)s")
item.taglinetext = taglinetext
if user_is_loggedin:
incr_counts(wrapped)

View File

@@ -222,24 +222,13 @@ ${parent.thing_data_attributes(what)} data-ups="${what.upvotes}" data-downs="${w
<%def name="tagline()">
<%
if thing.score_fmt == Score.points:
taglinetext = "<span>" + _("%(score)s submitted %(when)s ago%(lastedited)s") + "</span>"
if thing.different_sr:
taglinetext += " <span>" + _("by %(author)s to %(reddit)s") + "</span>"
else:
taglinetext += " <span>" + _("by %(author)s") + "</span>"
elif thing.different_sr:
taglinetext = _("submitted %(when)s ago%(lastedited)s by %(author)s to %(reddit)s")
else:
taglinetext = _("submitted %(when)s ago%(lastedited)s by %(author)s")
taglinetext = taglinetext.replace(" ", "&#32;")
taglinetext = thing.taglinetext.replace(" ", "&#32;")
%>
${unsafe(taglinetext % dict(reddit = self.subreddit(),
score = capture(self.score, thing, thing.likes, tag='span'),
when = capture(thing_timestamp, thing, thing.timesince),
author = WrappedUser(thing.author, thing.attribs, thing).render(),
lastedited = capture(edited, thing, thing.lastedited)
${unsafe(taglinetext % dict(reddit=self.subreddit(),
score=capture(self.score, thing, thing.likes, tag='span'),
when=capture(thing_timestamp, thing, thing.timesince),
author=WrappedUser(thing.author, thing.attribs, thing).render(),
lastedited=capture(edited, thing, thing.lastedited)
))}
</%def>