Vertaalbestanden 8: labels van de contactmail (Naam, E-mailadres, Onderwerp, Bericht) naar de Contact-module-tekstbestanden (contact.mail.label.*); karakteriseringstest eerst
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ Levend document (2026-11-15). De vaste, voor gebruikers bedoelde teksten van de
|
|||||||
| In de bestanden | Blijft in code |
|
| In de bestanden | Blijft in code |
|
||||||
|---|---|
|
|---|---|
|
||||||
| Mails: uitnodigingen, wachtwoord resetten, accountwijzigingen, melding van een contactbericht (`core.mail.*`) | CMS-data: pakketten, banners, categorieën, berichten van bezoekers |
|
| Mails: uitnodigingen, wachtwoord resetten, accountwijzigingen, melding van een contactbericht (`core.mail.*`) | CMS-data: pakketten, banners, categorieën, berichten van bezoekers |
|
||||||
|
| De labels voor de gegevens van de bezoeker in de mail aan de eigenaar: Naam, E-mailadres, Onderwerp, Bericht (`contact.mail.label.*`) | |
|
||||||
| Meldingen aan de beheerder bij inloggen, uitnodigen en eerste inrichting (`core.identity.*`) | Technische ProblemDetails-titels (`Validation failed`, `Too many requests`, `Service Unavailable`, `Unauthorized`, `Payload too large`, `Invalid category`) |
|
| Meldingen aan de beheerder bij inloggen, uitnodigen en eerste inrichting (`core.identity.*`) | Technische ProblemDetails-titels (`Validation failed`, `Too many requests`, `Service Unavailable`, `Unauthorized`, `Payload too large`, `Invalid category`) |
|
||||||
| Beschikbaarheidsmeldingen (`availability.*`) | Foutcodes van het contactformulier (`required`, `too_long`, `invalid`, ...): dat is een contract met de websites |
|
| Beschikbaarheidsmeldingen (`availability.*`) | Foutcodes van het contactformulier (`required`, `too_long`, `invalid`, ...): dat is een contract met de websites |
|
||||||
| Validatiemeldingen van pakketten en banners (`offerings.validation.*`) | Interne uitzonderingen (Master), log- en SecurityEvent-teksten |
|
| Validatiemeldingen van pakketten en banners (`offerings.validation.*`) | Interne uitzonderingen (Master), log- en SecurityEvent-teksten |
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using FluentAssertions;
|
||||||
|
using SlpModularCms.Core.Texts;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace SlpModularCms.Modules.Contact.Tests;
|
||||||
|
|
||||||
|
public class ContactTextsTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void TheTextFiles_MatchTheDeclaredKeys_InDutchAndEnglish()
|
||||||
|
=> TextAudit.Verify(typeof(ContactTexts).Assembly, TextAudit.KeysOf(typeof(ContactTexts)), "nl", "en").Should().BeEmpty();
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using SlpModularCms.Core.Texts;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Threading.RateLimiting;
|
using System.Threading.RateLimiting;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
@@ -28,6 +29,7 @@ public class ContactModule : IModule
|
|||||||
|
|
||||||
public void RegisterServices(IServiceCollection services)
|
public void RegisterServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
services.AddCmsTextsFrom(typeof(ContactModule).Assembly);
|
||||||
services.AddOptions<ContactOptions>()
|
services.AddOptions<ContactOptions>()
|
||||||
.Configure<IConfiguration>((options, config) =>
|
.Configure<IConfiguration>((options, config) =>
|
||||||
config.GetSection(ContactOptions.SectionName).Bind(options))
|
config.GetSection(ContactOptions.SectionName).Bind(options))
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using SlpModularCms.Core.Texts;
|
||||||
|
|
||||||
|
namespace SlpModularCms.Modules.Contact;
|
||||||
|
|
||||||
|
/// <summary>The keys of the Contact module's texts (<c>Texts/nl.json</c>, <c>Texts/en.json</c>, key path <c>contact.*</c>).</summary>
|
||||||
|
public static class ContactTexts
|
||||||
|
{
|
||||||
|
/// <summary>The labels in front of the visitor's details in the mail to the site owner.</summary>
|
||||||
|
public static class MailLabel
|
||||||
|
{
|
||||||
|
public static readonly TextKey Name = new("contact.mail.label.name");
|
||||||
|
public static readonly TextKey Email = new("contact.mail.label.email");
|
||||||
|
public static readonly TextKey Subject = new("contact.mail.label.subject");
|
||||||
|
public static readonly TextKey Message = new("contact.mail.label.message");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using SlpModularCms.Core.Email;
|
using SlpModularCms.Core.Email;
|
||||||
using SlpModularCms.Core.SiteSettings;
|
using SlpModularCms.Core.SiteSettings;
|
||||||
|
using SlpModularCms.Core.Texts;
|
||||||
using SlpModularCms.Modules.Contact.Config;
|
using SlpModularCms.Modules.Contact.Config;
|
||||||
using SlpModularCms.Modules.Contact.Data.Entities;
|
using SlpModularCms.Modules.Contact.Data.Entities;
|
||||||
|
|
||||||
@@ -23,7 +24,8 @@ public sealed class ContactMailSender(
|
|||||||
IOptions<EmailOptions> email,
|
IOptions<EmailOptions> email,
|
||||||
IOptions<AppMailOptions> app,
|
IOptions<AppMailOptions> app,
|
||||||
IOptions<ContactOptions> contact,
|
IOptions<ContactOptions> contact,
|
||||||
ILogger<ContactMailSender> logger) : IContactMailSender
|
ILogger<ContactMailSender> logger,
|
||||||
|
ITextCatalog? texts = null) : IContactMailSender
|
||||||
{
|
{
|
||||||
public async Task<string?> NotReadyReasonAsync(CancellationToken cancellationToken)
|
public async Task<string?> NotReadyReasonAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
@@ -51,7 +53,7 @@ public sealed class ContactMailSender(
|
|||||||
var (fromAddress, fromName) = await siteSettings.GetEffectiveSenderAsync(cancellationToken);
|
var (fromAddress, fromName) = await siteSettings.GetEffectiveSenderAsync(cancellationToken);
|
||||||
var baseUrl = app.Value.PublicBaseUrl.TrimEnd('/');
|
var baseUrl = app.Value.PublicBaseUrl.TrimEnd('/');
|
||||||
var language = languages.Resolve(null);
|
var language = languages.Resolve(null);
|
||||||
var dutch = language == MailLanguages.Dutch;
|
var text = texts ?? TextCatalog.Default;
|
||||||
|
|
||||||
var model = new MailModel(
|
var model = new MailModel(
|
||||||
SiteName: fromName,
|
SiteName: fromName,
|
||||||
@@ -60,10 +62,10 @@ public sealed class ContactMailSender(
|
|||||||
LogoDarkUrl: ResolveLogo(baseUrl, email.Value.LogoDarkUrl),
|
LogoDarkUrl: ResolveLogo(baseUrl, email.Value.LogoDarkUrl),
|
||||||
Details:
|
Details:
|
||||||
[
|
[
|
||||||
new MailDetail(dutch ? "Naam" : "Name", message.Name),
|
new MailDetail(text.Get(ContactTexts.MailLabel.Name, language), message.Name),
|
||||||
new MailDetail(dutch ? "E-mailadres" : "E-mail address", message.Email),
|
new MailDetail(text.Get(ContactTexts.MailLabel.Email, language), message.Email),
|
||||||
new MailDetail(dutch ? "Onderwerp" : "Subject", message.Subject),
|
new MailDetail(text.Get(ContactTexts.MailLabel.Subject, language), message.Subject),
|
||||||
new MailDetail(dutch ? "Bericht" : "Message", message.Message),
|
new MailDetail(text.Get(ContactTexts.MailLabel.Message, language), message.Message),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var rendered = renderer.Render(MailKind.ContactMessage, language, model);
|
var rendered = renderer.Render(MailKind.ContactMessage, language, model);
|
||||||
|
|||||||
@@ -16,4 +16,8 @@
|
|||||||
<ProjectReference Include="..\SlpModularCms.Core\SlpModularCms.Core.csproj" />
|
<ProjectReference Include="..\SlpModularCms.Core\SlpModularCms.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Texts\*.json" WithCulture="false" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"contact": {
|
||||||
|
"mail": {
|
||||||
|
"label": {
|
||||||
|
"name": "Name",
|
||||||
|
"email": "E-mail address",
|
||||||
|
"subject": "Subject",
|
||||||
|
"message": "Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"contact": {
|
||||||
|
"mail": {
|
||||||
|
"label": {
|
||||||
|
"name": "Naam",
|
||||||
|
"email": "E-mailadres",
|
||||||
|
"subject": "Onderwerp",
|
||||||
|
"message": "Bericht"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user