TWEEDE GEDRAGSWIJZIGING (goedgekeurd): de 13 Engelse antwoorden van auth/users zijn Nederlands bij Texts:DefaultLanguage=nl; en-bestand = oude tekst letterlijk. De admin toont voor wachtwoord vergeten zijn eigen tekst. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
93 lines
5.7 KiB
PowerShell
93 lines
5.7 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Writes docs/mail-teksten.md: a readable overview of every mail the CMS sends (the texts per kind in Dutch and English,
|
|
and the plain-text version of each Dutch and English example).
|
|
|
|
.DESCRIPTION
|
|
Reads src/SlpModularCms.Core/Texts/nl.json and en.json (the single source of the sentences) and the recorded example
|
|
mails in src/SlpModularCms.Core.Tests/Golden/mail. Run it after changing a mail text; the file is generated, do not
|
|
edit it by hand.
|
|
|
|
.EXAMPLE
|
|
./scripts/Export-MailTexts.ps1
|
|
#>
|
|
[CmdletBinding()]
|
|
param([string] $Output)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$here = if ($PSScriptRoot) { $PSScriptRoot } else { Split-Path -Parent $MyInvocation.MyCommand.Path }
|
|
$root = Resolve-Path (Join-Path $here '..')
|
|
if (-not $Output) { $Output = Join-Path $root 'docs\mail-teksten.md' }
|
|
$nl = Get-Content -LiteralPath (Join-Path $root 'src\SlpModularCms.Core\Texts\nl.json') -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
$en = Get-Content -LiteralPath (Join-Path $root 'src\SlpModularCms.Core\Texts\en.json') -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
$golden = Join-Path $root 'src\SlpModularCms.Core.Tests\Golden\mail'
|
|
|
|
$kinds = [ordered]@{
|
|
Invitation = @{ Key = 'invitation'; Title = 'Uitnodiging'; When = 'Een beheerder nodigt iemand uit.' }
|
|
NewInvitationLink = @{ Key = 'newInvitationLink'; Title = 'Nieuwe uitnodigingslink'; When = 'Een beheerder maakt een nieuwe uitnodigingslink aan.' }
|
|
PasswordReset = @{ Key = 'passwordReset'; Title = 'Wachtwoord opnieuw instellen'; When = 'Iemand vraagt een nieuw wachtwoord aan.' }
|
|
AccountDeactivated = @{ Key = 'accountDeactivated'; Title = 'Account gedeactiveerd'; When = 'Een beheerder deactiveert een account.' }
|
|
AccountReactivated = @{ Key = 'accountReactivated'; Title = 'Account weer actief'; When = 'Een beheerder activeert een account weer.' }
|
|
RoleChanged = @{ Key = 'roleChanged'; Title = 'Rol gewijzigd'; When = 'Een beheerder wijzigt de rol van een gebruiker.' }
|
|
ContactMessage = @{ Key = 'contactMessage'; Title = 'Nieuw contactbericht'; When = 'Een bezoeker verstuurt het contactformulier; de mail gaat naar de eigenaar van de site.' }
|
|
}
|
|
$parts = [ordered]@{ subject = 'Onderwerp'; heading = 'Kop'; intro = 'Inleiding'; button = 'Knop'; note = 'Opmerking onderaan' }
|
|
|
|
function Cell([string] $text) { if ([string]::IsNullOrEmpty($text)) { '-' } else { $text.Replace('|', '\|') } }
|
|
|
|
$sb = [System.Text.StringBuilder]::new()
|
|
[void]$sb.AppendLine('# Teksten van de mails van het CMS')
|
|
[void]$sb.AppendLine()
|
|
[void]$sb.AppendLine('Gegenereerd door `scripts/Export-MailTexts.ps1` uit `src/SlpModularCms.Core/Texts/nl.json` en `en.json` (en de voorbeeldmails in `src/SlpModularCms.Core.Tests/Golden/mail`). Niet met de hand wijzigen: pas de tekstbestanden aan en draai het script opnieuw. Zie [translation-files.md](translation-files.md) voor de opzet.')
|
|
[void]$sb.AppendLine()
|
|
[void]$sb.AppendLine('In de teksten staan plaatshouders tussen accolades die bij het versturen worden ingevuld: `{site}` (naam van de site), `{validity}` (hoe lang een link geldig is, bijvoorbeeld "48 uur" of "30 minuten"), `{role}` (de nieuwe rol) en `{name}` (naam van de ontvanger). Elke mail heeft bovenaan een kop, optioneel een aanhef, de inleiding, eventueel een knop met de link, een opmerking en onderaan een vaste voettekst.')
|
|
[void]$sb.AppendLine()
|
|
[void]$sb.AppendLine('## Vaste onderdelen')
|
|
[void]$sb.AppendLine()
|
|
[void]$sb.AppendLine('| Onderdeel | Nederlands | Engels |')
|
|
[void]$sb.AppendLine('|---|---|---|')
|
|
foreach ($row in @(
|
|
@('Aanhef (als de naam van de ontvanger bekend is)', 'greeting'),
|
|
@('Voettekst onder elke mail', 'footer'),
|
|
@('Rol: eigenaar', 'role.owner'), @('Rol: beheerder', 'role.administrator'), @('Rol: gebruiker', 'role.user'),
|
|
@('Geldigheid, 1 uur', 'validity.hoursOne'), @('Geldigheid, meerdere uren', 'validity.hoursOther'), @('Geldigheid, minuten', 'validity.minutes'))) {
|
|
$get = { param($o, $path) $v = $o.core.mail; foreach ($p in $path.Split('.')) { $v = $v.$p }; $v }
|
|
[void]$sb.AppendLine("| $($row[0]) | $(Cell (& $get $nl $row[1])) | $(Cell (& $get $en $row[1])) |")
|
|
}
|
|
|
|
foreach ($kind in $kinds.Keys) {
|
|
$info = $kinds[$kind]
|
|
[void]$sb.AppendLine()
|
|
[void]$sb.AppendLine("## $($info.Title)")
|
|
[void]$sb.AppendLine()
|
|
[void]$sb.AppendLine("Wanneer: $($info.When)")
|
|
[void]$sb.AppendLine()
|
|
[void]$sb.AppendLine('| Onderdeel | Nederlands | Engels |')
|
|
[void]$sb.AppendLine('|---|---|---|')
|
|
foreach ($part in $parts.Keys) {
|
|
$n = $nl.core.mail.($info.Key).$part
|
|
$e = $en.core.mail.($info.Key).$part
|
|
if (-not $n -and -not $e) { continue }
|
|
[void]$sb.AppendLine("| $($parts[$part]) | $(Cell $n) | $(Cell $e) |")
|
|
}
|
|
foreach ($lang in 'nl', 'en') {
|
|
$file = Join-Path $golden "$kind.$lang.full.txt"
|
|
if (-not (Test-Path $file)) { continue }
|
|
$text = (Get-Content -LiteralPath $file -Raw -Encoding UTF8) -replace "`r`n", "`n"
|
|
$idx = $text.IndexOf("--TEXT--`n")
|
|
if ($idx -lt 0) { continue }
|
|
$plain = $text.Substring($idx + 9).TrimEnd()
|
|
$label = if ($lang -eq 'nl') { 'Voorbeeld (tekstversie, Nederlands)' } else { 'Voorbeeld (tekstversie, Engels)' }
|
|
[void]$sb.AppendLine()
|
|
[void]$sb.AppendLine("**$label**, met voorbeeldwaarden (site 'Test <Site> & Co', ontvanger 'Jan ""de"" Vries'):")
|
|
[void]$sb.AppendLine()
|
|
[void]$sb.AppendLine('```text')
|
|
[void]$sb.AppendLine($plain)
|
|
[void]$sb.AppendLine('```')
|
|
}
|
|
}
|
|
|
|
$full = [System.IO.Path]::GetFullPath($Output)
|
|
[System.IO.File]::WriteAllText($full, $sb.ToString().Replace("`r`n", "`n"), [System.Text.UTF8Encoding]::new($false))
|
|
Write-Host "Written $full"
|