Using T.Plural in code

--HG--
branch : dev
This commit is contained in:
Louis DeJardin
2010-06-09 15:39:35 -07:00
parent a190d9bc64
commit 85a0f45c5d
11 changed files with 25 additions and 17 deletions

View File

@@ -10,16 +10,18 @@ if (Model.Entries.Count() > 0) { %>
entry.ContentItemViewModel.Zones.AddAction("meta", html => {
int draftCount = entry.TotalPostCount - entry.ContentItemViewModel.Item.PostCount;
int totalPostCount = entry.TotalPostCount;
var draftText = (draftCount == 0 ? "": string.Format(" ({0} draft{1})", draftCount, draftCount == 1 ? "" : "s"));
var linkText = T.Plural("1 post", "{0} posts", totalPostCount).ToString();
if (draftCount==0){
linkText = linkText + " (" + T.Plural("1 draft", "{0} drafts", draftCount).ToString() + ")";
}
var linkContent = _Encoded("{0} post{1}{2}", totalPostCount, totalPostCount == 1 ? "" : "s", draftText);
html.ViewContext.Writer.Write(html.Link(linkContent.ToString(), Url.BlogForAdmin(entry.ContentItemViewModel.Item.Slug)));
html.ViewContext.Writer.Write(html.Link(linkText, Url.BlogForAdmin(entry.ContentItemViewModel.Item.Slug)));
});
// Display the summary for the blog post
return Html.DisplayForItem(entry.ContentItemViewModel).ToHtmlString();
}, "blogs contentItems")%><%
} else { %>
<div class="info message"><%=T("There are no blogs for you to see. Want to <a href=\"{0}\">add one</a>?", Url.BlogCreate()).ToString()%></div><%
<div class="info message"><%:T("There are no blogs for you to see. Want to <a href=\"{0}\">add one</a>?", Url.BlogCreate())%></div><%
} %>

View File

@@ -4,4 +4,4 @@
<%@ Import Namespace="Orchard.Blogs.Models"%>
<h2><%=Html.Link(Html.Encode(Model.Item.Name), Url.Blog(Model.Item.Slug)) %></h2>
<% if (!string.IsNullOrEmpty(Model.Item.Description)) { %><p><%: Model.Item.Description %></p><% } %>
<div class="blog metadata"><%: T("{0} post{1}", Model.Item.PostCount, Model.Item.PostCount == 1 ? "" : "s")%> | <%Html.Zone("meta");%></div>
<div class="blog metadata"><%: T.Plural("1 post", "{0} posts", Model.Item.PostCount)%> | <%Html.Zone("meta");%></div>