mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Remove implicit conversion from string to LocalizedString
In most cases, relying on the implicit conversion is a sign of a missing call to "T". --HG-- branch : dev
This commit is contained in:
@@ -38,7 +38,7 @@ namespace Orchard.Core.Common.Drivers {
|
||||
updater.TryUpdateModel(model, Prefix, null, null);
|
||||
|
||||
if (!_routableService.IsSlugValid(part.Slug)){
|
||||
updater.AddModelError("Routable.Slug", T("Please do not use any of the following characters in your slugs: \"/\", \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\". No spaces are allowed (please use dashes or underscores instead).").ToString());
|
||||
updater.AddModelError("Routable.Slug", T("Please do not use any of the following characters in your slugs: \"/\", \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\". No spaces are allowed (please use dashes or underscores instead)."));
|
||||
}
|
||||
|
||||
string originalSlug = part.Slug;
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Navigation.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.UI.Navigation;
|
||||
using MenuItem=Orchard.Core.Navigation.Models.MenuItem;
|
||||
|
||||
@@ -36,11 +37,11 @@ namespace Orchard.Core.Navigation.Services {
|
||||
|
||||
if (part.Is<MenuItem>())
|
||||
builder.Add(
|
||||
menu => menu.Add(part.MenuText, part.MenuPosition, nib => nib.Url(part.As<MenuItem>().Url)));
|
||||
menu => menu.Add(new LocalizedString(part.MenuText), part.MenuPosition, nib => nib.Url(part.As<MenuItem>().Url)));
|
||||
else
|
||||
builder.Add(
|
||||
menu =>
|
||||
menu.Add(part.MenuText, part.MenuPosition,
|
||||
menu.Add(new LocalizedString(part.MenuText), part.MenuPosition,
|
||||
nib =>
|
||||
nib.Action(_contentManager.GetItemMetadata(part.ContentItem).DisplayRouteValues)));
|
||||
}
|
||||
|
@@ -83,7 +83,7 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
}
|
||||
|
||||
if (!_routableService.IsSlugValid(part.Slug)) {
|
||||
updater.AddModelError("Routable.Slug", T("Please do not use any of the following characters in your slugs: \"/\", \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\". No spaces are allowed (please use dashes or underscores instead).").ToString());
|
||||
updater.AddModelError("Routable.Slug", T("Please do not use any of the following characters in your slugs: \"/\", \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\". No spaces are allowed (please use dashes or underscores instead)."));
|
||||
}
|
||||
|
||||
string originalSlug = part.Slug;
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<li><%
|
||||
if (Model.Item.ScheduledPublishUtc.HasValue && Model.Item.ScheduledPublishUtc.Value > DateTime.UtcNow) { %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Blogs/Content/Admin/images/scheduled.gif") %>" alt="<%: T("Scheduled") %>" title="<%: T("The post is scheduled for publishing") %>" /><%: T("Scheduled")%>
|
||||
<%=Html.DateTime(Model.Item.ScheduledPublishUtc.Value, "M/d/yyyy h:mm tt")%><%
|
||||
<%=Html.DateTime(Model.Item.ScheduledPublishUtc.Value, T("M/d/yyyy h:mm tt"))%><%
|
||||
}
|
||||
else if (Model.Item.IsPublished) { %>
|
||||
<%: T("Published: {0}", Html.DateTimeRelative(Model.Item.As<ICommonAspect>().VersionPublishedUtc.Value, T)) %><%
|
||||
|
@@ -48,7 +48,7 @@ namespace Orchard.Comments.Controllers {
|
||||
|
||||
if(!TryUpdateModel(viewModel)) {
|
||||
if (Request.Form["Name"].IsNullOrEmptyTrimmed()) {
|
||||
_notifier.Error("You must provide a Name in order to comment");
|
||||
_notifier.Error(T("You must provide a Name in order to comment"));
|
||||
}
|
||||
return Redirect(returnUrl);
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ namespace Orchard.DevTools.Controllers {
|
||||
}
|
||||
|
||||
public ActionResult NotAuthorized() {
|
||||
_notifier.Warning("Simulated error goes here.");
|
||||
_notifier.Warning(T("Simulated error goes here."));
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
|
||||
|
@@ -42,7 +42,7 @@ namespace Orchard.Media.Controllers {
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error("Deleting Folder failed: " + exception.Message);
|
||||
Services.Notifier.Error(T("Deleting Folder failed: {0}", exception.Message));
|
||||
return View();
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ namespace Orchard.Media.Controllers {
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error("Creating Folder failed: " + exception.Message);
|
||||
Services.Notifier.Error(T("Creating Folder failed: {0}", exception.Message));
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace Orchard.Media.Controllers {
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error("Deleting failed: " + exception.Message);
|
||||
Services.Notifier.Error(T("Deleting failed: {0}", exception.Message));
|
||||
return View();
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ namespace Orchard.Media.Controllers {
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error("Modifying Folder Properties failed: " + exception.Message);
|
||||
Services.Notifier.Error(T("Modifying Folder Properties failed: {0}", exception.Message));
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
@@ -161,7 +161,7 @@ namespace Orchard.Media.Controllers {
|
||||
return RedirectToAction("Edit", new { name = viewModel.FolderName, mediaPath = viewModel.MediaPath });
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error("Uploading media file failed: " + exception.Message);
|
||||
Services.Notifier.Error(T("Uploading media file failed: {0}", exception.Message));
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
@@ -240,7 +240,7 @@ namespace Orchard.Media.Controllers {
|
||||
mediaPath = viewModel.MediaPath });
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error("Editing media file failed: " + exception.Message);
|
||||
Services.Notifier.Error(T("Editing media file failed: {0}", exception.Message));
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<FeaturesViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Localization" %>
|
||||
<%@ Import Namespace="Orchard.Modules.Extensions" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Modules.ViewModels"%>
|
||||
@@ -11,7 +12,7 @@
|
||||
<ul class="features summary-view switchable"><%
|
||||
var featureGroups = Model.Features.OrderBy(f => f.Descriptor.Category).GroupBy(f => f.Descriptor.Category);
|
||||
foreach (var featureGroup in featureGroups) {
|
||||
var categoryName = featureGroup.First().Descriptor.Category ?? T("Uncategorized");
|
||||
var categoryName = LocalizedString.TextOrDefault(featureGroup.First().Descriptor.Category, T("Uncategorized"));
|
||||
var categoryClassName = string.Format("category {0}", Html.Encode(categoryName.ToString().HtmlClassify()));
|
||||
if (featureGroup == featureGroups.First())
|
||||
categoryClassName += " first";
|
||||
|
@@ -55,7 +55,7 @@ namespace Orchard.MultiTenancy.Controllers {
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error(T("Creating Tenant failed: ") + exception.Message);
|
||||
Services.Notifier.Error(T("Creating Tenant failed: {0}", exception.Message));
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ namespace Orchard.MultiTenancy.Controllers {
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error(T("Failed to edit tenant: ") + exception.Message);
|
||||
Services.Notifier.Error(T("Failed to edit tenant: {0} ", exception.Message));
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
|
@@ -62,7 +62,7 @@ using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
<li><%
|
||||
if (pageEntry.Page.ScheduledPublishUtc.HasValue && pageEntry.Page.ScheduledPublishUtc.Value > DateTime.UtcNow) { %>
|
||||
<img class="icon" src="<%=ResolveUrl("~/Modules/Orchard.Pages/Content/Admin/images/scheduled.gif") %>" alt="<%: T("Scheduled") %>" title="<%: T("The page is scheduled for publishing") %>" /><%: T("Scheduled")%>
|
||||
<%=Html.DateTime(pageEntry.Page.ScheduledPublishUtc.Value, "M/d/yyyy h:mm tt")%><%
|
||||
<%=Html.DateTime(pageEntry.Page.ScheduledPublishUtc.Value, T("M/d/yyyy h:mm tt"))%><%
|
||||
}
|
||||
else if (pageEntry.Page.IsPublished) { %>
|
||||
<%: T("Published: {0}", Html.DateTimeRelative(pageEntry.Page.As<ICommonAspect>().VersionPublishedUtc.Value, T)) %><%
|
||||
|
@@ -25,6 +25,7 @@ namespace Orchard.Roles.Controllers {
|
||||
Services = services;
|
||||
_roleService = roleService;
|
||||
_authorizationService = authorizationService;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public IOrchardServices Services { get; set; }
|
||||
@@ -55,7 +56,7 @@ namespace Orchard.Roles.Controllers {
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error("Deleting Role failed: " + exception.Message);
|
||||
Services.Notifier.Error(T("Deleting Role failed: {0}", exception.Message));
|
||||
return View();
|
||||
}
|
||||
}
|
||||
@@ -87,7 +88,7 @@ namespace Orchard.Roles.Controllers {
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error("Creating Role failed: " + exception.Message);
|
||||
Services.Notifier.Error(T("Creating Role failed: {0}", exception.Message));
|
||||
return RedirectToAction("Create");
|
||||
}
|
||||
}
|
||||
@@ -141,7 +142,7 @@ namespace Orchard.Roles.Controllers {
|
||||
return RedirectToAction("Edit", new { viewModel.Id });
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error("Editing Role failed: " + exception.Message);
|
||||
Services.Notifier.Error(T("Editing Role failed: {0}", exception.Message));
|
||||
return RedirectToAction("Edit", viewModel.Id);
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Data;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Roles.Models;
|
||||
using Orchard.Roles.Services;
|
||||
using Orchard.Roles.ViewModels;
|
||||
@@ -29,6 +30,7 @@ namespace Orchard.Roles.Drivers {
|
||||
_notifier = notifier;
|
||||
_authenticationService = authenticationService;
|
||||
_authorizationService = authorizationService;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
protected override string Prefix {
|
||||
@@ -37,6 +39,8 @@ namespace Orchard.Roles.Drivers {
|
||||
}
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
protected override DriverResult Editor(UserRoles userRoles) {
|
||||
// don't show editor without apply roles permission
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ApplyRoles, _authenticationService.GetAuthenticatedUser(), userRoles))
|
||||
@@ -75,12 +79,12 @@ namespace Orchard.Roles.Drivers {
|
||||
var targetRoleRecords = model.Roles.Where(x => x.Granted).Select(x => _roleService.GetRole(x.RoleId));
|
||||
|
||||
foreach (var addingRole in targetRoleRecords.Where(x => !currentRoleRecords.Contains(x))) {
|
||||
_notifier.Warning(string.Format("Adding role {0} to user {1}", addingRole.Name, userRoles.As<IUser>().UserName));
|
||||
_notifier.Warning(T("Adding role {0} to user {1}", addingRole.Name, userRoles.As<IUser>().UserName));
|
||||
_userRolesRepository.Create(new UserRolesRecord { UserId = model.User.Id, Role = addingRole });
|
||||
}
|
||||
|
||||
foreach (var removingRole in currentUserRoleRecords.Where(x => !targetRoleRecords.Contains(x.Role))) {
|
||||
_notifier.Warning(string.Format("Removing role {0} from user {1}", removingRole.Role.Name, userRoles.As<IUser>().UserName));
|
||||
_notifier.Warning(T("Removing role {0} from user {1}", removingRole.Role.Name, userRoles.As<IUser>().UserName));
|
||||
_userRolesRepository.Delete(removingRole);
|
||||
}
|
||||
|
||||
|
@@ -84,7 +84,7 @@ namespace Orchard.Setup.Controllers {
|
||||
catch (Exception exception) {
|
||||
_notifier.Error(T("Setup failed:"));
|
||||
for (var scan = exception; scan != null; scan = scan.InnerException) {
|
||||
_notifier.Error(scan.Message);
|
||||
_notifier.Error(new LocalizedString(scan.Message));
|
||||
}
|
||||
return IndexViewResult(model);
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ namespace Orchard.Themes.Services {
|
||||
|
||||
public void ZoneRendering(ZoneRenderContext context) {
|
||||
#if DEBUG
|
||||
context.Html.ViewContext.Writer.WriteLine(T("<!-- begin zone: {0} -->", context.ZoneName ?? T("etc. (ZonesAny)")));
|
||||
context.Html.ViewContext.Writer.WriteLine(T("<!-- begin zone: {0} -->", LocalizedString.TextOrDefault(context.ZoneName, T("etc. (ZonesAny)"))));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Orchard.Themes.Services {
|
||||
|
||||
public void ZoneRendered(ZoneRenderContext context) {
|
||||
#if DEBUG
|
||||
context.Html.ViewContext.Writer.WriteLine(T("<!-- end zone: {0} -->", context.ZoneName ?? T("etc. (ZonesAny)")));
|
||||
context.Html.ViewContext.Writer.WriteLine(T("<!-- end zone: {0} -->", LocalizedString.TextOrDefault(context.ZoneName, T("etc. (ZonesAny)"))));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user