Skip to content

Commit db24271

Browse files
authored
Merge pull request #626 from cloudscribe/feature/998
#998 ensuring translatable strings are in place
2 parents 6e46a05 + b5235a2 commit db24271

6 files changed

Lines changed: 26 additions & 22 deletions

File tree

src/cloudscribe.SimpleContent.CompiledViews.Bootstrap5/Views/Shared/CommentFormPartial.cshtml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@model cloudscribe.SimpleContent.Web.ViewModels.BlogViewModel
22
@using cloudscribe.SimpleContent.Models
33
@using cloudscribe.SimpleContent.Web
4-
4+
@inject IStringLocalizer<SimpleContent> sr
55

66
@{
77
var path = Url.Action("AjaxPostComment", "Blog");
@@ -10,28 +10,28 @@
1010
}
1111
<form id="commentform" asp-antiforgery="true" class="form-horizontal" data-blog-path="@path">
1212
<fieldset>
13-
<legend>Post comment</legend>
13+
<legend>@sr["Post comment"]</legend>
1414

1515
<div class="mb-3 row">
16-
<label for="commentname" class="control-label col-sm-2">Name</label>
16+
<label for="commentname" class="control-label col-sm-2">@sr["Name"]</label>
1717
<div class="col-sm-7">
1818
<input id="commentname" class="form-control" type="text" placeholder="Name" required />
1919
</div>
2020
</div>
2121
<div class="mb-3 row">
22-
<label for="commentemail" class="control-label col-sm-2">Email</label>
22+
<label for="commentemail" class="control-label col-sm-2">@sr["Email"]</label>
2323
<div class="col-sm-7">
2424
<input id="commentemail" class="form-control" type="email" placeholder="Email" required />
2525
</div>
2626
</div>
2727
<div class="mb-3 row">
28-
<label for="commenturl" class="control-label col-sm-2">Website</label>
28+
<label for="commenturl" class="control-label col-sm-2">@sr["Website"]</label>
2929
<div class="col-sm-7">
3030
<input id="commenturl" class="form-control" type="url" placeholder="Website URL" />
3131
</div>
3232
</div>
3333
<div class="mb-3 row">
34-
<label for="commentcontent" class="control-label col-sm-2">Comment (no HTML allowed)</label>
34+
<label for="commentcontent" class="control-label col-sm-2">@sr["Comment (no HTML allowed)"]</label>
3535
<div class="col-sm-10">
3636
<textarea id="commentcontent" class="form-control" rows="4" placeholder="Comment" required></textarea>
3737
</div>
@@ -49,7 +49,7 @@
4949
<div class="mb-3 row">
5050
<div class="col-sm-offset-2 col-sm-10">
5151
<input name="postId2" type="hidden" value="@Model.CurrentPost.Id" />
52-
<button class="btn btn-primary">Post comment</button>
52+
<button class="btn btn-primary">@sr["Post comment"]</button>
5353
<span id="status" class="alert" role="status" aria-live="polite"></span>
5454
</div>
5555
</div>

src/cloudscribe.SimpleContent.CompiledViews.Bootstrap5/Views/Shared/CommentPartial.cshtml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
@using cloudscribe.SimpleContent.Web
33
@addTagHelper "*, cloudscribe.Web.Common"
44
@model cloudscribe.SimpleContent.Web.ViewModels.BlogViewModel
5+
@inject IStringLocalizer<SimpleContent> sr
6+
57
<article data-id="@Model.TmpComment.Id" itemscope itemtype="http://schema.org/UserComments" itemprop="comment" class="@(Model.TmpComment.IsAdmin ? "self" : null)">
68
<img gravatar-email="@Model.TmpComment.Email" gravatar-size="50" alt="Comment by @Model.TmpComment.Author" />
79
<div class="comment-item">
@@ -17,7 +19,7 @@
1719
}
1820
@if (Model.CanEdit)
1921
{
20-
<button class="deletecomment btn btn-link">Delete</button>
22+
<button class="deletecomment btn btn-link">@sr["Delete"]</button>
2123
@if (Model.ProjectSettings.ModerateComments && !Model.TmpComment.IsApproved)
2224
{
2325
<button class="approvecomment btn btn-link">Approve</button>
@@ -26,6 +28,6 @@
2628
</div>
2729
@if (Model.ProjectSettings.ModerateComments && !Model.TmpComment.IsApproved && !Model.CanEdit)
2830
{
29-
<div itemprop="approvalWarning">! The comment will not be visible until a moderator approves it !</div>
31+
<div itemprop="approvalWarning">@sr["! The comment will not be visible until a moderator approves it !"]</div>
3032
}
3133
</article>

src/cloudscribe.SimpleContent.Syndication/RssChannelProvider.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.AspNetCore.Mvc;
1313
using Microsoft.AspNetCore.Mvc.Infrastructure;
1414
using Microsoft.AspNetCore.Mvc.Routing;
15+
using Microsoft.Extensions.Localization;
1516
using System;
1617
using System.Collections.Generic;
1718
using System.Globalization;
@@ -30,7 +31,8 @@ public RssChannelProvider(
3031
IHttpContextAccessor contextAccessor,
3132
IUrlHelperFactory urlHelperFactory,
3233
IActionContextAccessor actionContextAccesor,
33-
IContentProcessor contentProcessor
34+
IContentProcessor contentProcessor,
35+
IStringLocalizer<RssChannelProvider> localizer
3436
)
3537
{
3638
ProjectService = projectService;
@@ -41,6 +43,7 @@ IContentProcessor contentProcessor
4143
ActionContextAccesor = actionContextAccesor;
4244
ContentProcessor = contentProcessor;
4345
BlogRoutes = blogRoutes;
46+
sr = localizer;
4447
}
4548

4649
protected IUrlHelperFactory UrlHelperFactory { get; private set; }
@@ -51,7 +54,7 @@ IContentProcessor contentProcessor
5154
protected IBlogRoutes BlogRoutes { get; private set; }
5255
protected IContentProcessor ContentProcessor { get; private set; }
5356
protected IBlogUrlResolver BlogUrlResolver { get; private set; }
54-
57+
protected IStringLocalizer sr { get; private set; }
5558

5659
public string Name { get; } = "cloudscribe.SimpleContent.Syndication.RssChannelProvider";
5760

@@ -87,7 +90,7 @@ IContentProcessor contentProcessor
8790
else
8891
{
8992
// prevent error, channel desc cannot be empty
90-
channel.Description = "Welcome to my blog";
93+
channel.Description = sr["Welcome to my blog"];
9194
}
9295

9396
if(!string.IsNullOrEmpty(project.ChannelCategoriesCsv))
@@ -199,8 +202,7 @@ IContentProcessor contentProcessor
199202
rssItem.Description = filteredResult.FilteredContent;
200203
if(!filteredResult.IsFullContent)
201204
{
202-
//TODO: localize
203-
var readMore = " <a href='" + postUrl + "'>...read more</a>";
205+
var readMore = " <a href='" + postUrl + "'>" + sr["...read more"] + "</a>";
204206
rssItem.Description += readMore;
205207
}
206208

src/cloudscribe.SimpleContent.Web/Controllers/BlogController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@ public virtual async Task<IActionResult> AjaxPostComment(CommentViewModel model)
13081308
Log.LogDebug("returning 403 because no content was posted");
13091309
Response.StatusCode = 403;
13101310
//await Response.WriteAsync("Please enter a valid content");
1311-
return Content("Please enter a valid content");
1311+
return Content(StringLocalizer["Please enter valid content"]);
13121312
}
13131313

13141314
var blogPost = await BlogService.GetPost(model.PostId);
@@ -1329,7 +1329,7 @@ public virtual async Task<IActionResult> AjaxPostComment(CommentViewModel model)
13291329
Log.LogDebug("returning 403 captcha validation failed");
13301330
Response.StatusCode = 403;
13311331
//await Response.WriteAsync("captcha validation failed");
1332-
return Content("captcha validation failed");
1332+
return Content(StringLocalizer["captcha validation failed"]);
13331333
}
13341334
}
13351335
}

src/cloudscribe.SimpleContent.Web/Controllers/PageController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ public virtual async Task<IActionResult> Index(
123123
if (HttpContext.Request.Path == "/")
124124
{
125125
ViewData["Title"] = StringLocalizer["Home"];
126-
page.Title = "No pages found, please click the plus icon to create the home page";
126+
page.Title = StringLocalizer["No pages found, please click the plus icon to create the home page"];
127127
}
128128
else
129129
{
130130
ViewData["Title"] = StringLocalizer["No Pages Found"];
131-
page.Title = "No pages found, please click the plus icon to create the first page";
131+
page.Title = StringLocalizer["No pages found, please click the plus icon to create the first page"];
132132
}
133133
}
134134
else

src/cloudscribe.SimpleContent.Web/Services/Page/PageService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public async Task<PageActionResult> Move(PageMoveModel model)
227227

228228
if (string.IsNullOrEmpty(model.MovedNode) || string.IsNullOrEmpty(model.TargetNode) || (model.MovedNode == "-1") || (model.TargetNode == "-1") || (string.IsNullOrEmpty(model.Position)))
229229
{
230-
result = new PageActionResult(false, "bad request, failed to move page");
230+
result = new PageActionResult(false, _sr["bad request, failed to move page"]);
231231
return result;
232232
}
233233

@@ -236,7 +236,7 @@ public async Task<PageActionResult> Move(PageMoveModel model)
236236

237237
if ((movedNode == null) || (targetNode == null))
238238
{
239-
result = new PageActionResult(false, "bad request, page or target page not found");
239+
result = new PageActionResult(false, _sr["bad request, page or target page not found"]);
240240
return result;
241241
}
242242

@@ -308,7 +308,7 @@ public async Task<PageActionResult> Move(PageMoveModel model)
308308

309309
//ClearNavigationCache();
310310

311-
result = new PageActionResult(true, "operation succeeded");
311+
result = new PageActionResult(true, _sr["operation succeeded"]);
312312

313313
await _eventHandlers.HandleMoved(_settings.Id, movedNode, targetNode, model.Position).ConfigureAwait(false);
314314

@@ -340,7 +340,7 @@ public async Task<PageActionResult> SortChildPagesAlpha(string pageId)
340340
}
341341

342342
//ClearNavigationCache();
343-
return new PageActionResult(true, "operation succeeded");
343+
return new PageActionResult(true, _sr["operation succeeded"]);
344344

345345
}
346346

0 commit comments

Comments
 (0)