From 39c62e142fcfd7b2e5e0e4930af4e38996977a4e Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Thu, 10 Jun 2010 11:36:44 -0700 Subject: [PATCH] Localized (and properly pluralized) a couple of HtmlHelper extensions (around friendly published datetimes) --HG-- branch : dev --- .../Extensions/HtmlHelperExtensions.cs | 17 +++++----- .../Items/Blogs.BlogPost.Summary.ascx | 4 +-- .../Items/Blogs.BlogPost.SummaryAdmin.ascx | 11 +++---- .../Blogs.BlogPost.Metadata.Summary.ascx | 2 +- .../Parts/Blogs.BlogPost.Metadata.ascx | 2 +- .../Views/ListOfComments.ascx | 2 +- .../Orchard.Pages/Views/Admin/List.aspx | 9 +++-- .../Orchard.Search/Views/Admin/Index.ascx | 2 +- .../Items/Blogs.BlogPost.Summary.ascx | 4 +-- .../Parts/Blogs.BlogPost.Metadata.ascx | 9 +++-- .../Items/Blogs.BlogPost.Summary.ascx | 4 +-- .../Parts/Blogs.BlogPost.Metadata.ascx | 9 +++-- .../Themes/Contoso/Views/ListOfComments.ascx | 15 ++++----- .../Corporate/Views/ListOfComments.ascx | 15 ++++----- .../Items/Blogs.BlogPost.Summary.ascx | 9 ++--- .../Parts/Blogs.BlogPost.Metadata.ascx | 9 +++-- .../Themes/Green/Views/ListOfComments.ascx | 15 ++++----- src/Orchard/Mvc/Html/HtmlHelperExtensions.cs | 33 ++++++++++--------- 18 files changed, 74 insertions(+), 97 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Extensions/HtmlHelperExtensions.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Extensions/HtmlHelperExtensions.cs index 30724ae32..7560d079f 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Extensions/HtmlHelperExtensions.cs +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Extensions/HtmlHelperExtensions.cs @@ -2,24 +2,25 @@ using System.Web.Mvc; using Orchard.Blogs.Models; using Orchard.ContentManagement; using Orchard.ContentManagement.Aspects; +using Orchard.Localization; using Orchard.Mvc.Html; namespace Orchard.Blogs.Extensions { public static class HtmlHelperExtensions { - public static string PublishedState(this HtmlHelper htmlHelper) { - return htmlHelper.PublishedState(htmlHelper.ViewData.Model); + public static LocalizedString PublishedState(this HtmlHelper htmlHelper, Localizer T) { + return htmlHelper.PublishedState(htmlHelper.ViewData.Model, T); } - public static string PublishedState(this HtmlHelper htmlHelper, BlogPost blogPost) { - return htmlHelper.DateTime(blogPost.As().VersionPublishedUtc, "Draft"); + public static LocalizedString PublishedState(this HtmlHelper htmlHelper, BlogPost blogPost, Localizer T) { + return htmlHelper.DateTime(blogPost.As().VersionPublishedUtc, T("Draft")); } - public static string PublishedWhen(this HtmlHelper htmlHelper) { - return htmlHelper.PublishedWhen(htmlHelper.ViewData.Model); + public static LocalizedString PublishedWhen(this HtmlHelper htmlHelper, Localizer T) { + return htmlHelper.PublishedWhen(htmlHelper.ViewData.Model, T); } - public static string PublishedWhen(this HtmlHelper htmlHelper, BlogPost blogPost) { - return htmlHelper.DateTimeRelative(blogPost.As().VersionPublishedUtc, "as a Draft"); + public static LocalizedString PublishedWhen(this HtmlHelper htmlHelper, BlogPost blogPost, Localizer T) { + return htmlHelper.DateTimeRelative(blogPost.As().VersionPublishedUtc, T("as a Draft"), T); } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx index 31650d86f..ab3177a20 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx @@ -1,9 +1,7 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>" %> -<%@ Import Namespace="Orchard.ContentManagement"%> -<%@ Import Namespace="Orchard.Core.Common.Models"%> <%@ Import Namespace="Orchard.Mvc.ViewModels"%> <%@ Import Namespace="Orchard.Blogs.Extensions"%> <%@ Import Namespace="Orchard.Blogs.Models"%>

<%=Html.Link(Html.Encode(Model.Item.Title), Url.BlogPost(Model.Item)) %>

-
<%=Html.PublishedState(Model.Item) %> | <%Html.Zone("meta");%>
+
<%=Html.PublishedState(Model.Item, T) %> | <%Html.Zone("meta");%>
<% Html.Zone("primary", ":manage :metadata");%>
diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Items/Blogs.BlogPost.SummaryAdmin.ascx b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Items/Blogs.BlogPost.SummaryAdmin.ascx index 748288226..a75a35aa9 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Items/Blogs.BlogPost.SummaryAdmin.ascx +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Items/Blogs.BlogPost.SummaryAdmin.ascx @@ -1,7 +1,6 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>" %> <%@ Import Namespace="Orchard.ContentManagement.Aspects"%> <%@ Import Namespace="Orchard.ContentManagement"%> -<%@ Import Namespace="Orchard.Core.Common.Models"%> <%@ Import Namespace="Orchard.Mvc.ViewModels"%> <%@ Import Namespace="Orchard.Blogs.Extensions"%> <%@ Import Namespace="Orchard.Blogs.Models"%> @@ -11,15 +10,15 @@
  • <% if (Model.Item.HasPublished) { %> - " alt="<%: T("Online") %>" title="<%: T("The page is currently online") %>" /><%: T(" Published")%><% + " alt="<%: T("Online") %>" title="<%: T("The page is currently online") %>" /> <%: T("Published")%><% } else { %> - " alt="<%: T("Offline") %>" title="<%: T("The page is currently offline") %>" /><%: T(" Not Published")%><% + " alt="<%: T("Offline") %>" title="<%: T("The page is currently offline") %>" /> <%: T("Not Published")%><% } %> | 
  • <% if (Model.Item.HasDraft) { %> - " alt="<%: T("Draft") %>" title="<%: T("The post has a draft") %>" /><%=Html.PublishedState(Model.Item)%><% + " alt="<%: T("Draft") %>" title="<%: T("The post has a draft") %>" /><%=Html.PublishedState(Model.Item, T) %><% } else { %> <%: T("No draft")%><% @@ -31,10 +30,10 @@ <%=Html.DateTime(Model.Item.ScheduledPublishUtc.Value, "M/d/yyyy h:mm tt")%><% } else if (Model.Item.IsPublished) { %> - <%: T("Published: ") + Html.DateTimeRelative(Model.Item.As().VersionPublishedUtc.Value)%><% + <%: T("Published: {0}", Html.DateTimeRelative(Model.Item.As().VersionPublishedUtc.Value, T)) %><% } else { %> - <%: T("Last modified: ") + Html.DateTimeRelative(Model.Item.As().ModifiedUtc.Value) %><% + <%: T("Last modified: {0}", Html.DateTimeRelative(Model.Item.As().ModifiedUtc.Value, T)) %><% } %> | 
  • <%: T("By {0}", Model.Item.Creator.UserName)%>
  • diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.Summary.ascx b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.Summary.ascx index c46697732..402274d10 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.Summary.ascx +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.Summary.ascx @@ -2,5 +2,5 @@ <%@ Import Namespace="Orchard.Blogs.Extensions"%> <%@ Import Namespace="Orchard.Blogs.Models"%><% if (Model.Creator != null) { - %><%: T("Posted by {0} {1}", Model.Creator.UserName, Html.PublishedWhen(Model)) %> | <% + %><%: T("Posted by {0} {1}", Model.Creator.UserName, Html.PublishedWhen(Model, T)) %> | <% } %> \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx index ae7698531..a54802281 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx @@ -3,6 +3,6 @@ <%@ Import Namespace="Orchard.Blogs.Models"%> \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Views/ListOfComments.ascx b/src/Orchard.Web/Modules/Orchard.Comments/Views/ListOfComments.ascx index b92e64e06..789fc37d7 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Views/ListOfComments.ascx +++ b/src/Orchard.Web/Modules/Orchard.Comments/Views/ListOfComments.ascx @@ -6,7 +6,7 @@ foreach (var comment in Model) { %>
    <%=Html.LinkOrDefault(Html.Encode(comment.Record.UserName), Html.Encode(comment.Record.SiteName), new { rel = "nofollow" })%> <%-- todo: (heskew) need comment permalink --%> - said <%=Html.Link(Html.DateTimeRelative(comment.Record.CommentDateUtc.GetValueOrDefault()), "#")%> + said <%=Html.Link(Html.DateTimeRelative(comment.Record.CommentDateUtc.GetValueOrDefault(), T).Text, "#")%>
    <%-- todo: (heskew) comment text needs processing depending on comment markup style --%> diff --git a/src/Orchard.Web/Modules/Orchard.Pages/Views/Admin/List.aspx b/src/Orchard.Web/Modules/Orchard.Pages/Views/Admin/List.aspx index 2851aaa6f..f9f514bd2 100644 --- a/src/Orchard.Web/Modules/Orchard.Pages/Views/Admin/List.aspx +++ b/src/Orchard.Web/Modules/Orchard.Pages/Views/Admin/List.aspx @@ -1,7 +1,6 @@ <%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage" %> <%@ Import Namespace="Orchard.ContentManagement.Aspects"%> <%@ Import Namespace="Orchard.ContentManagement"%> -<%@ Import Namespace="Orchard.Core.Common.Models"%> <%@ Import Namespace="Orchard.Mvc.Html"%> <%@ Import Namespace="Orchard.Pages.ViewModels"%><% Html.RegisterStyle("admin.css"); %> @@ -45,10 +44,10 @@ using (Html.BeginFormAntiForgeryPost()) { %>
  • <% // Published or not if (pageEntry.Page.HasPublished) { %> - " alt="<%: T("Online") %>" title="<%: T("The page is currently online") %>" /><%: T("Published") %> | <% + " alt="<%: T("Online") %>" title="<%: T("The page is currently online") %>" /> <%: T("Published") %> | <% } else { %> - " alt="<%: T("Offline") %>" title="<%: T("The page is currently offline") %>" /><%: T("Not Published")%> | <% + " alt="<%: T("Offline") %>" title="<%: T("The page is currently offline") %>" /> <%: T("Not Published")%> | <% } %>
  • <% @@ -66,10 +65,10 @@ using (Html.BeginFormAntiForgeryPost()) { %> <%=Html.DateTime(pageEntry.Page.ScheduledPublishUtc.Value, "M/d/yyyy h:mm tt")%><% } else if (pageEntry.Page.IsPublished) { %> - <%: T("Published: ") + Html.DateTimeRelative(pageEntry.Page.As().VersionPublishedUtc.Value) %><% + <%: T("Published: {0}", Html.DateTimeRelative(pageEntry.Page.As().VersionPublishedUtc.Value, T)) %><% } else { %> - <%: T("Last modified: ") + Html.DateTimeRelative(pageEntry.Page.As().ModifiedUtc.Value) %><% + <%: T("Last modified: {0}", Html.DateTimeRelative(pageEntry.Page.As().ModifiedUtc.Value, T)) %><% } %> | 
  • <%: T("By {0}", pageEntry.Page.Creator.UserName)%>
  • diff --git a/src/Orchard.Web/Modules/Orchard.Search/Views/Admin/Index.ascx b/src/Orchard.Web/Modules/Orchard.Search/Views/Admin/Index.ascx index 151100a64..e7202166b 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/Views/Admin/Index.ascx +++ b/src/Orchard.Web/Modules/Orchard.Search/Views/Admin/Index.ascx @@ -4,7 +4,7 @@ Html.RegisterStyle("admin.css"); %>

    <%=Html.TitleForPage(T("Search Index Management").ToString()) %>

    <% using (Html.BeginForm("update", "admin", FormMethod.Post, new {area = "Orchard.Search"})) { %>
    -

    <%=T("The search index was last updated {0}. ", Html.DateTimeRelative(Model.IndexUpdatedUtc))%>

    +

    <%=T("The search index was last updated {0}. ", Html.DateTimeRelative(Model.IndexUpdatedUtc, T))%>

    <%=Html.AntiForgeryTokenOrchard() %>
    <% } diff --git a/src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx b/src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx index 2037687d2..637da3b4b 100644 --- a/src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx +++ b/src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx @@ -1,12 +1,10 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>" %> -<%@ Import Namespace="Orchard.ContentManagement"%> -<%@ Import Namespace="Orchard.Core.Common.Models"%> <%@ Import Namespace="Orchard.Mvc.ViewModels"%> <%@ Import Namespace="Orchard.Blogs.Extensions"%> <%@ Import Namespace="Orchard.Blogs.Models"%> <%Model.Zones.AddRenderPartial("zonetest", "ZoneTest", Model); %>

    <%=Html.Link(Html.Encode(Model.Item.Title), Url.BlogPost(Model.Item)) %>

    -
    <%=Html.PublishedState(Model.Item) %> | <%Html.Zone("meta");%>
    +
    <%=Html.PublishedState(Model.Item, T) %> | <%Html.Zone("meta");%>
    <% Html.Zone("primary"); %>
    \ No newline at end of file diff --git a/src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx b/src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx index 623e3985c..e91472533 100644 --- a/src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx +++ b/src/Orchard.Web/Themes/Classic/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx @@ -1,7 +1,6 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> <%@ Import Namespace="Orchard.Blogs.Extensions"%> -<%@ Import Namespace="Orchard.Blogs.Models"%> -<% - if (Model.Creator != null) { - %><%: T("Posted by {0} {1}", Model.Creator.UserName, "|", Html.PublishedWhen(Model)) %><% - } %> +<%@ Import Namespace="Orchard.Blogs.Models"%><% +if (Model.Creator != null) { + %><%: T("Posted by {0} {1}", Model.Creator.UserName, Html.PublishedWhen(Model, T)) %><% +} %> \ No newline at end of file diff --git a/src/Orchard.Web/Themes/ClassicDark/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx b/src/Orchard.Web/Themes/ClassicDark/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx index 2037687d2..637da3b4b 100644 --- a/src/Orchard.Web/Themes/ClassicDark/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx +++ b/src/Orchard.Web/Themes/ClassicDark/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx @@ -1,12 +1,10 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>" %> -<%@ Import Namespace="Orchard.ContentManagement"%> -<%@ Import Namespace="Orchard.Core.Common.Models"%> <%@ Import Namespace="Orchard.Mvc.ViewModels"%> <%@ Import Namespace="Orchard.Blogs.Extensions"%> <%@ Import Namespace="Orchard.Blogs.Models"%> <%Model.Zones.AddRenderPartial("zonetest", "ZoneTest", Model); %>

    <%=Html.Link(Html.Encode(Model.Item.Title), Url.BlogPost(Model.Item)) %>

    -
    <%=Html.PublishedState(Model.Item) %> | <%Html.Zone("meta");%>
    +
    <%=Html.PublishedState(Model.Item, T) %> | <%Html.Zone("meta");%>
    <% Html.Zone("primary"); %>
    \ No newline at end of file diff --git a/src/Orchard.Web/Themes/ClassicDark/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx b/src/Orchard.Web/Themes/ClassicDark/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx index 623e3985c..e91472533 100644 --- a/src/Orchard.Web/Themes/ClassicDark/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx +++ b/src/Orchard.Web/Themes/ClassicDark/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx @@ -1,7 +1,6 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> <%@ Import Namespace="Orchard.Blogs.Extensions"%> -<%@ Import Namespace="Orchard.Blogs.Models"%> -<% - if (Model.Creator != null) { - %><%: T("Posted by {0} {1}", Model.Creator.UserName, "|", Html.PublishedWhen(Model)) %><% - } %> +<%@ Import Namespace="Orchard.Blogs.Models"%><% +if (Model.Creator != null) { + %><%: T("Posted by {0} {1}", Model.Creator.UserName, Html.PublishedWhen(Model, T)) %><% +} %> \ No newline at end of file diff --git a/src/Orchard.Web/Themes/Contoso/Views/ListOfComments.ascx b/src/Orchard.Web/Themes/Contoso/Views/ListOfComments.ascx index c86a1eea1..17545b07d 100644 --- a/src/Orchard.Web/Themes/Contoso/Views/ListOfComments.ascx +++ b/src/Orchard.Web/Themes/Contoso/Views/ListOfComments.ascx @@ -3,15 +3,12 @@
      <% foreach (var comment in Model) { %>
    • - -
      -

      <%: comment.Record.CommentText %>

      -
      - -
      -<%=Html.LinkOrDefault(Html.Encode(comment.Record.UserName), Html.Encode(comment.Record.SiteName), new { rel = "nofollow" })%> said <%=Html.Link(Html.DateTimeRelative(comment.Record.CommentDateUtc.GetValueOrDefault()), "#")%> -
      - +
      +

      <%: comment.Record.CommentText %>

      +
      +
      + <%=Html.LinkOrDefault(Html.Encode(comment.Record.UserName), Html.Encode(comment.Record.SiteName), new { rel = "nofollow" })%> said <%=Html.Link(Html.DateTimeRelative(comment.Record.CommentDateUtc.GetValueOrDefault(), T).Text, "#")%> +
    • <% } %>
    diff --git a/src/Orchard.Web/Themes/Corporate/Views/ListOfComments.ascx b/src/Orchard.Web/Themes/Corporate/Views/ListOfComments.ascx index c86a1eea1..17545b07d 100644 --- a/src/Orchard.Web/Themes/Corporate/Views/ListOfComments.ascx +++ b/src/Orchard.Web/Themes/Corporate/Views/ListOfComments.ascx @@ -3,15 +3,12 @@
      <% foreach (var comment in Model) { %>
    • - -
      -

      <%: comment.Record.CommentText %>

      -
      - -
      -<%=Html.LinkOrDefault(Html.Encode(comment.Record.UserName), Html.Encode(comment.Record.SiteName), new { rel = "nofollow" })%> said <%=Html.Link(Html.DateTimeRelative(comment.Record.CommentDateUtc.GetValueOrDefault()), "#")%> -
      - +
      +

      <%: comment.Record.CommentText %>

      +
      +
      + <%=Html.LinkOrDefault(Html.Encode(comment.Record.UserName), Html.Encode(comment.Record.SiteName), new { rel = "nofollow" })%> said <%=Html.Link(Html.DateTimeRelative(comment.Record.CommentDateUtc.GetValueOrDefault(), T).Text, "#")%> +
    • <% } %>
    diff --git a/src/Orchard.Web/Themes/Green/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx b/src/Orchard.Web/Themes/Green/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx index 52e19c18c..bd4a18de9 100644 --- a/src/Orchard.Web/Themes/Green/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx +++ b/src/Orchard.Web/Themes/Green/Views/DisplayTemplates/Items/Blogs.BlogPost.Summary.ascx @@ -1,14 +1,9 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl>" %> -<%@ Import Namespace="Orchard.ContentManagement"%> -<%@ Import Namespace="Orchard.Core.Common.Models"%> <%@ Import Namespace="Orchard.Mvc.ViewModels"%> <%@ Import Namespace="Orchard.Blogs.Extensions"%> <%@ Import Namespace="Orchard.Blogs.Models"%> -

    <%=Html.Link(Html.Encode(Model.Item.Title), Url.BlogPost(Model.Item)) %>

    - -
    <%=Html.PublishedState(Model.Item) %> | <%Html.Zone("meta");%>
    - +
    <%=Html.PublishedState(Model.Item, T) %> | <%Html.Zone("meta");%>
    <% Html.Zone("primary"); %> -
    +
    \ No newline at end of file diff --git a/src/Orchard.Web/Themes/Green/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx b/src/Orchard.Web/Themes/Green/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx index 623e3985c..e91472533 100644 --- a/src/Orchard.Web/Themes/Green/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx +++ b/src/Orchard.Web/Themes/Green/Views/DisplayTemplates/Parts/Blogs.BlogPost.Metadata.ascx @@ -1,7 +1,6 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> <%@ Import Namespace="Orchard.Blogs.Extensions"%> -<%@ Import Namespace="Orchard.Blogs.Models"%> -<% - if (Model.Creator != null) { - %><%: T("Posted by {0} {1}", Model.Creator.UserName, "|", Html.PublishedWhen(Model)) %><% - } %> +<%@ Import Namespace="Orchard.Blogs.Models"%><% +if (Model.Creator != null) { + %><%: T("Posted by {0} {1}", Model.Creator.UserName, Html.PublishedWhen(Model, T)) %><% +} %> \ No newline at end of file diff --git a/src/Orchard.Web/Themes/Green/Views/ListOfComments.ascx b/src/Orchard.Web/Themes/Green/Views/ListOfComments.ascx index c86a1eea1..17545b07d 100644 --- a/src/Orchard.Web/Themes/Green/Views/ListOfComments.ascx +++ b/src/Orchard.Web/Themes/Green/Views/ListOfComments.ascx @@ -3,15 +3,12 @@
      <% foreach (var comment in Model) { %>
    • - -
      -

      <%: comment.Record.CommentText %>

      -
      - -
      -<%=Html.LinkOrDefault(Html.Encode(comment.Record.UserName), Html.Encode(comment.Record.SiteName), new { rel = "nofollow" })%> said <%=Html.Link(Html.DateTimeRelative(comment.Record.CommentDateUtc.GetValueOrDefault()), "#")%> -
      - +
      +

      <%: comment.Record.CommentText %>

      +
      +
      + <%=Html.LinkOrDefault(Html.Encode(comment.Record.UserName), Html.Encode(comment.Record.SiteName), new { rel = "nofollow" })%> said <%=Html.Link(Html.DateTimeRelative(comment.Record.CommentDateUtc.GetValueOrDefault(), T).Text, "#")%> +
    • <% } %>
    diff --git a/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs b/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs index b38925545..cdd150db4 100644 --- a/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs +++ b/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs @@ -7,6 +7,7 @@ using System.Web.Mvc; using System.Web.Mvc.Html; using System.Web.Routing; using Orchard.Collections; +using Orchard.Localization; using Orchard.Mvc.ViewModels; using Orchard.Services; using Orchard.Settings; @@ -178,44 +179,44 @@ namespace Orchard.Mvc.Html { #region Format Date/Time - public static string DateTimeRelative(this HtmlHelper htmlHelper, DateTime? value, string defaultIfNull) { - return value.HasValue ? htmlHelper.DateTimeRelative(value.Value) : defaultIfNull; + public static LocalizedString DateTimeRelative(this HtmlHelper htmlHelper, DateTime? value, LocalizedString defaultIfNull, Localizer T) { + return value.HasValue ? htmlHelper.DateTimeRelative(value.Value, T) : defaultIfNull; } //TODO: (erikpo) This method needs localized - public static string DateTimeRelative(this HtmlHelper htmlHelper, DateTime value) { - TimeSpan time = htmlHelper.Resolve().UtcNow - value; + public static LocalizedString DateTimeRelative(this HtmlHelper htmlHelper, DateTime value, Localizer T) { + var time = htmlHelper.Resolve().UtcNow - value; if (time.TotalDays > 7) - return "on " + htmlHelper.DateTime(value, "MMM d yyyy 'at' h:mm tt"); + return htmlHelper.DateTime(value, T("'on' MMM d yyyy 'at' h:mm tt")); if (time.TotalHours > 24) - return string.Format("{0} day{1} ago", time.Days, time.Days == 1 ? "" : "s"); + return T.Plural("1 day ago", "{0} days ago", time.Days); if (time.TotalMinutes > 60) - return string.Format("{0} hour{1} ago", time.Hours, time.Hours == 1 ? "" : "s"); + return T.Plural("1 hour ago", "{0} hours ago", time.Hours); if (time.TotalSeconds > 60) - return string.Format("{0} minute{1} ago", time.Minutes, time.Minutes == 1 ? "" : "s"); + return T.Plural("1 minute ago", "{0} minutes ago", time.Minutes); if (time.TotalSeconds > 10) - return string.Format("{0} second{1} ago", time.Seconds, time.Seconds == 1 ? "" : "s"); + return T.Plural("1 second ago", "{0} seconds ago", time.Seconds); - return "a moment ago"; + return T("a moment ago"); } - public static string DateTime(this HtmlHelper htmlHelper, DateTime? value, string defaultIfNull) { + public static LocalizedString DateTime(this HtmlHelper htmlHelper, DateTime? value, LocalizedString defaultIfNull) { return value.HasValue ? htmlHelper.DateTime(value.Value) : defaultIfNull; } - public static string DateTime(this HtmlHelper htmlHelper, DateTime? value, string defaultIfNull, string customFormat) { + public static LocalizedString DateTime(this HtmlHelper htmlHelper, DateTime? value, LocalizedString defaultIfNull, LocalizedString customFormat) { return value.HasValue ? htmlHelper.DateTime(value.Value, customFormat) : defaultIfNull; } - public static string DateTime(this HtmlHelper htmlHelper, DateTime value) { + public static LocalizedString DateTime(this HtmlHelper htmlHelper, DateTime value) { //TODO: (erikpo) This default format should come from a site setting - return htmlHelper.DateTime(value, "MMM d yyyy h:mm tt"); + return htmlHelper.DateTime(value, new LocalizedString("MMM d yyyy h:mm tt")); //todo: above comment and get rid of just wrapping this as a localized string } - public static string DateTime(this HtmlHelper htmlHelper, DateTime value, string customFormat) { + public static LocalizedString DateTime(this HtmlHelper htmlHelper, DateTime value, LocalizedString customFormat) { //TODO: (erikpo) In the future, convert this to "local" time before calling ToString - return value.ToString(customFormat); + return value.ToString(customFormat.Text); } #endregion