Translatable server texts and a Dutch language file #33
No files matched your search
@@ -10,6 +10,9 @@ the section is the text of the release in Gitea.
|
||||
`IriksIT\Manager\Support\Names` to ask for either. The defaults are the names of every earlier version.
|
||||
- `manager:import posts|pages|reviews` copies the rows of a table of the site into the package (read-only on the source, repeatable,
|
||||
`--dry-run`, column mapping).
|
||||
- Server texts are translatable: menu, permission labels and sections, theme names, audit summaries and the main messages go through `__()`,
|
||||
and the package ships `resources/lang/nl.json`. A site's own `lang/<locale>.json` wins.
|
||||
- Fix: the audit log and the bot counter strip the configured route-name prefix, not a fixed `manager.`.
|
||||
|
||||
## v0.4.0 - 2026-12-04
|
||||
|
||||
|
||||
@@ -53,6 +53,10 @@ Switch a part in `config/manager.php` (`modules`) or with `MANAGER_PAGES`, `MANA
|
||||
its migrations are not loaded at all. A module that needs another one (`requires()`) fails at boot when
|
||||
that one is off.
|
||||
|
||||
## Language
|
||||
|
||||
The texts the server makes (menu, permission and section labels, theme names, audit summaries and the messages of the JSON routes) go through Laravel's `__()` with the English text as the key. The package ships `resources/lang/nl.json`; the screens follow `app()->getLocale()`. A site translates more, or words things differently, with its own `lang/<locale>.json`: that file wins over the package. Audit lines are written in the language of the request that made them.
|
||||
|
||||
## A site with data and names of its own
|
||||
|
||||
The package never maps its queries onto other tables: every screen assumes its own columns. What it does give you is room to coexist and a way to move data in.
|
||||
|
||||
@@ -34,3 +34,4 @@ Per stuk werk een rij; zie `dev/token-usage.py`.
|
||||
| 2026-12-04 | TypeScript 7 niet voorstellen zolang vue-tsc het niet draait, en de PR van de eerste run rechtgezet | - | claude-sonnet-5-5 | 10 | 4.340 | 26 | 4.489 | 3.503.406 | 0,05 |
|
||||
| 2026-12-04 | Namen die kunnen verhuizen (route_name, tables) en manager:import voor bestaande gegevens | - | claude-sonnet-5-5 | 25 | 17.827 | 54 | 72.997 | 2.216.503 | 0,09 |
|
||||
| 2026-12-04 | Namen die kunnen verhuizen (route_name, tables) en manager:import voor bestaande gegevens | - | claude-fable-5-2 | 1 | 5.062 | 61.001 | 0 | 0 | 0,00 |
|
||||
| 2026-12-04 | Teksten van de server vertaalbaar met lang-bestanden en een Nederlandse vertaling | - | claude-sonnet-5-5 | 14 | 11.377 | 28 | 23.146 | 1.520.289 | 0,02 |
|
||||
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"Audit log": "Auditlog",
|
||||
"Banned an address": "Een adres geblokkeerd",
|
||||
"Lifted the ban of an address": "De blokkade van een adres opgeheven",
|
||||
"Banned the addresses of a group": "De adressen van een groep geblokkeerd",
|
||||
"Lifted the bans of a group": "De blokkades van een groep opgeheven",
|
||||
"Wrote or removed the note about an address": "Een notitie over een adres geschreven of verwijderd",
|
||||
"Changed the rules of the audit log": "De regels van de auditlog gewijzigd",
|
||||
"Opened the audit log": "De auditlog geopend",
|
||||
"See the audit log: who logged in and what was done, with addresses and browsers": "De auditlog zien: wie er inlogde en wat er gedaan is, met adressen en browsers",
|
||||
"Ban addresses and lift bans, write notes about addresses, and set the rules of the audit log": "Adressen blokkeren en weer vrijgeven, notities over adressen schrijven en de regels van de auditlog instellen",
|
||||
"Media": "Media",
|
||||
"Uploaded a file": "Een bestand geüpload",
|
||||
"Changed a file": "Een bestand gewijzigd",
|
||||
"Deleted a file": "Een bestand verwijderd",
|
||||
"Opened the media library": "De mediabibliotheek geopend",
|
||||
"See the media library and pick files from it": "De mediabibliotheek zien en er bestanden uit kiezen",
|
||||
"Upload files": "Bestanden uploaden",
|
||||
"Change the name, description and focus point of a file": "De naam, omschrijving en het scherpstelpunt van een bestand wijzigen",
|
||||
"Delete files": "Bestanden verwijderen",
|
||||
"Pages": "Pagina's",
|
||||
"Opened the pages": "De pagina's geopend",
|
||||
"Change the texts of the pages": "De teksten van de pagina's wijzigen",
|
||||
"Site content": "Inhoud van de site",
|
||||
"Posts": "Berichten",
|
||||
"Categories and tags": "Categorieën en tags",
|
||||
"Created a post": "Een bericht gemaakt",
|
||||
"Changed a post": "Een bericht gewijzigd",
|
||||
"Put a post on the site, or took it off": "Een bericht online gezet of offline gehaald",
|
||||
"Deleted a post": "Een bericht verwijderd",
|
||||
"Made a category or tag": "Een categorie of tag gemaakt",
|
||||
"Renamed a category or tag": "Een categorie of tag hernoemd",
|
||||
"Removed a category or tag": "Een categorie of tag verwijderd",
|
||||
"Opened the posts": "De berichten geopend",
|
||||
"Opened the form for a new post": "Het formulier voor een nieuw bericht geopend",
|
||||
"Opened a post": "Een bericht geopend",
|
||||
"Opened the preview of a post": "De voorvertoning van een bericht geopend",
|
||||
"Opened the categories and tags": "De categorieën en tags geopend",
|
||||
"See the posts, drafts included": "De berichten zien, concepten inbegrepen",
|
||||
"Write posts: create drafts and change them": "Berichten schrijven: concepten maken en wijzigen",
|
||||
"Publish, schedule and unpublish posts, and change posts that are live": "Berichten publiceren, plannen en offline halen, en berichten wijzigen die online staan",
|
||||
"Delete posts (one that is live only together with publishing)": "Berichten verwijderen (een online bericht alleen samen met publiceren)",
|
||||
"Manage the categories and tags: make them, and rename, merge and remove them on all posts": "De categorieën en tags beheren: maken, hernoemen, samenvoegen en verwijderen op alle berichten",
|
||||
"Reviews": "Reviews",
|
||||
"Opened the reviews": "De reviews geopend",
|
||||
"Manage the reviews": "De reviews beheren",
|
||||
"Statistics": "Statistieken",
|
||||
"Exported the statistics": "De statistieken geëxporteerd",
|
||||
"Opened the statistics": "De statistieken geopend",
|
||||
"See the visitor statistics and download them": "De bezoekersstatistieken zien en downloaden",
|
||||
"Accounts": "Accounts",
|
||||
"Groups": "Groepen",
|
||||
"Created an account": "Een account aangemaakt",
|
||||
"Changed an account": "Een account gewijzigd",
|
||||
"Deleted an account": "Een account verwijderd",
|
||||
"Created a group": "Een groep aangemaakt",
|
||||
"Changed a group": "Een groep gewijzigd",
|
||||
"Deleted a group": "Een groep verwijderd",
|
||||
"Opened the accounts": "De accounts geopend",
|
||||
"Opened the groups": "De groepen geopend",
|
||||
"Create, change and delete accounts, and put them in groups": "Accounts maken, wijzigen en verwijderen, en in groepen zetten",
|
||||
"Users": "Gebruikers",
|
||||
"Changed own account": "Eigen account gewijzigd",
|
||||
"Logged in": "Ingelogd",
|
||||
"Logged out": "Uitgelogd",
|
||||
"Asked for :request": ":request opgevraagd",
|
||||
"Was not allowed: :what": "Mocht dit niet: :what",
|
||||
"The address was banned after too many failed logins": "Het adres is geblokkeerd na te veel mislukte inlogpogingen",
|
||||
"Dark": "Donker",
|
||||
"Light": "Licht",
|
||||
"category": "categorie",
|
||||
"tag": "tag",
|
||||
"The :type \":name\" already exists.": "De :type \":name\" bestaat al.",
|
||||
"You cannot delete your own account.": "Je kunt je eigen account niet verwijderen.",
|
||||
"Another account already uses this email address.": "Een ander account gebruikt dit e-mailadres al.",
|
||||
"You can only choose groups that allow nothing more than your own account.": "Je kunt alleen groepen kiezen die niet meer toestaan dan je eigen account.",
|
||||
"The current password is not right.": "Het huidige wachtwoord klopt niet.",
|
||||
"The media library is full: this file does not fit in the room that is left. Remove files that are no longer used, or raise manager.media.max_total_gb.": "De mediabibliotheek is vol: dit bestand past niet in de ruimte die over is. Verwijder bestanden die niet meer gebruikt worden, of verhoog manager.media.max_total_gb.",
|
||||
"The file storage is not available right now. Try again in a moment.": "De bestandsopslag is nu niet beschikbaar. Probeer het zo opnieuw.",
|
||||
":ip is banned from the whole site.": ":ip is geblokkeerd voor de hele site.",
|
||||
":ip is banned from the manager.": ":ip is geblokkeerd voor de manager.",
|
||||
"The ban of :ip is lifted.": "De blokkade van :ip is opgeheven.",
|
||||
"The note about :ip is removed.": "De notitie over :ip is verwijderd.",
|
||||
"The note about :ip is saved.": "De notitie over :ip is opgeslagen.",
|
||||
"Rules saved.": "Regels opgeslagen.",
|
||||
"That is the address you are on yourself.": "Dat is het adres waar je zelf op zit.",
|
||||
"This address is on the list that is never banned.": "Dit adres staat op de lijst die nooit geblokkeerd wordt.",
|
||||
"this site": "deze site",
|
||||
"the manager": "de manager",
|
||||
"This address is blocked from :where.": "Dit adres is geblokkeerd voor :where.",
|
||||
"This address is blocked from :where until :when.": "Dit adres is geblokkeerd voor :where tot :when."
|
||||
}
|
||||
@@ -24,7 +24,7 @@ class ProfileController
|
||||
'groups' => method_exists($user, 'managerGroups') ? $user->managerGroups()->pluck('name')->values() : [],
|
||||
'theme' => $themes->keyFor($user),
|
||||
'themes' => config('manager.user_themes')
|
||||
? collect($themes->all())->map(fn (array $theme, string $key) => ['key' => $key, 'label' => $theme['label'], 'colors' => $theme['colors']])->values()
|
||||
? collect($themes->all())->map(fn (array $theme, string $key) => ['key' => $key, 'label' => __($theme['label']), 'colors' => $theme['colors']])->values()
|
||||
: [],
|
||||
]]);
|
||||
}
|
||||
@@ -42,7 +42,7 @@ class ProfileController
|
||||
]);
|
||||
|
||||
if (($data['password'] ?? '') !== '' && ! Hash::check((string) ($data['current_password'] ?? ''), $user->getAuthPassword())) {
|
||||
return response()->json(['message' => 'The current password is not right.', 'errors' => ['current_password' => ['The current password is not right.']]], 422);
|
||||
return response()->json(['message' => $wrong = __('The current password is not right.'), 'errors' => ['current_password' => [$wrong]]], 422);
|
||||
}
|
||||
|
||||
$user->name = $data['name'];
|
||||
|
||||
@@ -35,6 +35,7 @@ class ManagerServiceProvider extends ServiceProvider
|
||||
$modules->validate();
|
||||
|
||||
$this->publishes([__DIR__.'/../config/manager.php' => config_path('manager.php')], 'manager-config');
|
||||
$this->loadJsonTranslationsFrom(__DIR__.'/../resources/lang');
|
||||
$this->loadViewsFrom(__DIR__.'/../resources/views', 'manager');
|
||||
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ class AuditController
|
||||
$this->trail->about($ban);
|
||||
}
|
||||
|
||||
return response()->json(['message' => $wholeSite ? "{$ip} is banned from the whole site." : "{$ip} is banned from the manager."], 201);
|
||||
return response()->json(['message' => $wholeSite ? __(':ip is banned from the whole site.', ['ip' => $ip]) : __(':ip is banned from the manager.', ['ip' => $ip])], 201);
|
||||
}
|
||||
|
||||
public function unban(int $ban): JsonResponse
|
||||
@@ -180,7 +180,7 @@ class AuditController
|
||||
$this->trail->about($ipBan);
|
||||
$this->bans->lift($ipBan);
|
||||
|
||||
return response()->json(['message' => "The ban of {$ipBan->ip} is lifted."]);
|
||||
return response()->json(['message' => __('The ban of :ip is lifted.', ['ip' => $ipBan->ip])]);
|
||||
}
|
||||
|
||||
/** Bans every address of a group at once, with the same time, reason and reach. */
|
||||
@@ -258,7 +258,7 @@ class AuditController
|
||||
$note->delete();
|
||||
}
|
||||
|
||||
return response()->json(['message' => "The note about {$ip} is removed."]);
|
||||
return response()->json(['message' => __('The note about :ip is removed.', ['ip' => $ip])]);
|
||||
}
|
||||
|
||||
$note ??= new IpNote(['ip' => $ip]);
|
||||
@@ -267,7 +267,7 @@ class AuditController
|
||||
$note->fill(['note' => $text, 'group_name' => $group !== '' ? $group : null, 'user_id' => $user?->getAuthIdentifier(), 'user_name' => is_string($name) ? $name : null])->save();
|
||||
$this->trail->about($note);
|
||||
|
||||
return response()->json(['message' => "The note about {$ip} is saved."]);
|
||||
return response()->json(['message' => __('The note about :ip is saved.', ['ip' => $ip])]);
|
||||
}
|
||||
|
||||
public function settings(Request $request): JsonResponse
|
||||
@@ -284,12 +284,12 @@ class AuditController
|
||||
|
||||
AuditSetting::current()->forceFill(['id' => 1, ...$rules])->save();
|
||||
|
||||
return response()->json(['message' => 'Rules saved.', 'settings' => AuditSetting::current()->rules()]);
|
||||
return response()->json(['message' => __('Rules saved.'), 'settings' => AuditSetting::current()->rules()]);
|
||||
}
|
||||
|
||||
private function refuse(string $field, string $message): JsonResponse
|
||||
{
|
||||
return response()->json(['message' => $message, 'errors' => [$field => [$message]]], 422);
|
||||
return response()->json(['message' => $message = __($message), 'errors' => [$field => [$message]]], 422);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -115,13 +115,13 @@ class AuditModule extends BaseModule
|
||||
|
||||
Event::listen(Login::class, function (Login $event) use ($model) {
|
||||
if ($event->user instanceof $model) {
|
||||
app(AuditTrail::class)->record(AuditLog::LOGIN, 'Logged in', $event->user);
|
||||
app(AuditTrail::class)->record(AuditLog::LOGIN, __('Logged in'), $event->user);
|
||||
}
|
||||
});
|
||||
|
||||
Event::listen(Logout::class, function (Logout $event) use ($model) {
|
||||
if ($event->user instanceof $model) {
|
||||
app(AuditTrail::class)->record(AuditLog::LOGOUT, 'Logged out', $event->user);
|
||||
app(AuditTrail::class)->record(AuditLog::LOGOUT, __('Logged out'), $event->user);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ final class IpBans
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->trail->record(AuditLog::BAN, 'The address was banned after too many failed logins', subject: $ban, details: ['failures' => $failures]);
|
||||
$this->trail->record(AuditLog::BAN, __('The address was banned after too many failed logins'), subject: $ban, details: ['failures' => $failures]);
|
||||
|
||||
return $ban;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ use Illuminate\Support\Str;
|
||||
use IriksIT\Manager\Models\AuditLog;
|
||||
use IriksIT\Manager\Support\AuditTrail;
|
||||
use IriksIT\Manager\Support\ModuleRegistry;
|
||||
use IriksIT\Manager\Support\Names;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Throwable;
|
||||
@@ -50,18 +51,18 @@ class RecordActions
|
||||
|
||||
private function write(Request $request, Response $response, Authenticatable $user, ?Model $subject): void
|
||||
{
|
||||
$route = Str::after((string) $request->route()?->getName(), 'manager.');
|
||||
$route = Str::after((string) $request->route()?->getName(), Names::routePrefix());
|
||||
$actions = $this->modules->actions();
|
||||
$views = $this->modules->views();
|
||||
$thrown = property_exists($response, 'exception') && $response->exception instanceof Throwable ? $response->exception : null;
|
||||
$details = $this->details($request, $actions[$route][1] ?? []);
|
||||
$name = $actions[$route][0] ?? ($views[$route] ?? '');
|
||||
$name = $name !== '' ? $name : 'Asked for '.$request->method().' /'.ltrim($request->path(), '/');
|
||||
$name = $name !== '' ? __($name) : __('Asked for :request', ['request' => $request->method().' /'.ltrim($request->path(), '/')]);
|
||||
|
||||
if ($thrown !== null) {
|
||||
// Only a refusal is worth a line; a form with a mistake or a page that is not there is not.
|
||||
if ($thrown instanceof AuthorizationException || ($thrown instanceof HttpExceptionInterface && $thrown->getStatusCode() === 403)) {
|
||||
$this->trail->record(AuditLog::REFUSED, 'Was not allowed: '.Str::lcfirst($name), $user, $subject, $details, $route);
|
||||
$this->trail->record(AuditLog::REFUSED, __('Was not allowed: :what', ['what' => Str::lcfirst($name)]), $user, $subject, $details, $route);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -74,7 +75,7 @@ class RecordActions
|
||||
$changes = ! in_array($request->method(), ['GET', 'HEAD', 'OPTIONS'], true);
|
||||
|
||||
if (! $changes && ! isset($actions[$route])) {
|
||||
$this->viewed($user, $route, $views[$route] ?? '', $subject, $details);
|
||||
$this->viewed($user, $route, __($views[$route] ?? ''), $subject, $details);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ class RefuseBannedAddress
|
||||
/** The page (or JSON) a banned address gets, also for a ban on the whole site. */
|
||||
public static function answer(Request $request, IpBan $ban): Response
|
||||
{
|
||||
$where = $ban->whole_site ? 'this site' : 'the manager';
|
||||
$where = $ban->whole_site ? __('this site') : __('the manager');
|
||||
$message = $ban->expires_at === null
|
||||
? "This address is blocked from {$where}."
|
||||
: "This address is blocked from {$where} until ".$ban->expires_at->format('j F Y, H:i').'.';
|
||||
? __('This address is blocked from :where.', ['where' => $where])
|
||||
: __('This address is blocked from :where until :when.', ['where' => $where, 'when' => $ban->expires_at->format('j F Y, H:i')]);
|
||||
|
||||
// A ban that followed too many attempts is "429 Too Many Requests" and says when to come
|
||||
// back; one that was given by hand is a plain "403 Forbidden".
|
||||
|
||||
@@ -49,7 +49,7 @@ class MediaController
|
||||
$room = $this->library->room();
|
||||
|
||||
if ($file->getSize() > $room['left']) {
|
||||
$message = 'The media library is full: this file does not fit in the room that is left. Remove files that are no longer used, or raise manager.media.max_total_gb.';
|
||||
$message = __('The media library is full: this file does not fit in the room that is left. Remove files that are no longer used, or raise manager.media.max_total_gb.');
|
||||
|
||||
return response()->json(['message' => $message, 'errors' => ['file' => [$message]], 'storage' => $room], 422);
|
||||
}
|
||||
@@ -130,7 +130,7 @@ class MediaController
|
||||
{
|
||||
Log::warning('Media storage failed.', ['error' => $e->getMessage(), 'status' => $e->status]);
|
||||
|
||||
return response()->json(['message' => self::UNAVAILABLE], 502);
|
||||
return response()->json(['message' => __(self::UNAVAILABLE)], 502);
|
||||
}
|
||||
|
||||
/** @return array{max_file_mb: int, extensions: list<string>, storage: array{used: int, limit: int, left: int}} */
|
||||
|
||||
@@ -28,7 +28,7 @@ class LabelController
|
||||
$name = $request->string('name')->trim()->toString();
|
||||
|
||||
if (! $this->labels->create($type, $name)) {
|
||||
return response()->json(['message' => "The {$type} \"{$name}\" already exists.", 'errors' => ['name' => ["The {$type} \"{$name}\" already exists."]]], 422);
|
||||
return response()->json(['message' => $already = __('The :type ":name" already exists.', ['type' => __($type), 'name' => $name]), 'errors' => ['name' => [$already]]], 422);
|
||||
}
|
||||
|
||||
return response()->json(['created' => $name], 201);
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace IriksIT\Manager\Modules\Statistics;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use IriksIT\Manager\Support\Names;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Throwable;
|
||||
|
||||
@@ -42,7 +43,7 @@ class CountBots
|
||||
return $request->isMethod('GET')
|
||||
&& $response->getStatusCode() === 200
|
||||
&& is_string($name)
|
||||
&& ! str_starts_with($name, 'manager.')
|
||||
&& ! str_starts_with($name, Names::routePrefix())
|
||||
// The same promise as for visitors: who asks not to be followed is not counted at all.
|
||||
&& $request->header('Sec-GPC') !== '1'
|
||||
&& $request->header('DNT') !== '1';
|
||||
|
||||
@@ -103,7 +103,7 @@ class AccountController
|
||||
app(AuditTrail::class)->about($user);
|
||||
|
||||
if ($user->is($me)) {
|
||||
return response()->json(['message' => 'You cannot delete your own account.'], 422);
|
||||
return response()->json(['message' => __('You cannot delete your own account.')], 422);
|
||||
}
|
||||
|
||||
$user->managerGroups()->detach();
|
||||
@@ -144,7 +144,7 @@ class AccountController
|
||||
$email = $request->string('email')->trim()->lower()->toString();
|
||||
|
||||
if ($this->model()::query()->where('email', $email)->when($user !== null, fn ($query) => $query->whereKeyNot($user->getKey()))->exists()) {
|
||||
throw ValidationException::withMessages(['email' => 'Another account already uses this email address.']);
|
||||
throw ValidationException::withMessages(['email' => __('Another account already uses this email address.')]);
|
||||
}
|
||||
|
||||
return ['name' => $request->string('name')->trim()->toString(), 'email' => $email];
|
||||
@@ -163,7 +163,7 @@ class AccountController
|
||||
$groups = Group::query()->whereKey($ids)->get();
|
||||
|
||||
if ($groups->count() !== count($ids) || $groups->contains(fn (Group $group) => ! $me->managerMayGive($group))) {
|
||||
throw ValidationException::withMessages(['groups' => 'You can only choose groups that allow nothing more than your own account.']);
|
||||
throw ValidationException::withMessages(['groups' => __('You can only choose groups that allow nothing more than your own account.')]);
|
||||
}
|
||||
|
||||
return $ids;
|
||||
|
||||
@@ -120,7 +120,7 @@ final class ModuleRegistry
|
||||
$sections = [];
|
||||
|
||||
foreach ($this->permissions() as $permission) {
|
||||
$sections[$permission->section][] = ['value' => $permission->value, 'label' => $permission->label, 'needs' => $permission->needs];
|
||||
$sections[__($permission->section)][] = ['value' => $permission->value, 'label' => __($permission->label), 'needs' => $permission->needs];
|
||||
}
|
||||
|
||||
$catalogue = [];
|
||||
@@ -137,7 +137,7 @@ final class ModuleRegistry
|
||||
$items = [];
|
||||
|
||||
foreach ($this->active() as $module) {
|
||||
array_push($items, ...$module->navigation());
|
||||
array_push($items, ...array_map(fn (array $item) => [...$item, 'label' => __($item['label'])], $module->navigation()));
|
||||
}
|
||||
|
||||
return $items;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace IriksIT\Manager\Tests;
|
||||
|
||||
/** A site with every module switched on. */
|
||||
abstract class AllModulesTestCase extends TestCase
|
||||
{
|
||||
protected array $modules = ['reviews' => true, 'audit' => true, 'statistics' => true, 'pages' => true, 'posts' => true];
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
use IriksIT\Manager\Support\ModuleRegistry;
|
||||
use IriksIT\Manager\Tests\AllModulesTestCase;
|
||||
|
||||
uses(AllModulesTestCase::class);
|
||||
|
||||
it('has a Dutch text for every label the modules give', function () {
|
||||
$registry = app(ModuleRegistry::class);
|
||||
$english = [];
|
||||
|
||||
foreach ($registry->active() as $module) {
|
||||
$english[] = $module->label();
|
||||
|
||||
foreach ($module->permissions() as $permission) {
|
||||
array_push($english, $permission->label, $permission->section);
|
||||
}
|
||||
|
||||
foreach ($module->navigation() as $item) {
|
||||
$english[] = $item['label'];
|
||||
}
|
||||
|
||||
foreach ($module->actions() as $action) {
|
||||
$english[] = $action[0];
|
||||
}
|
||||
|
||||
array_push($english, ...array_values($module->views()));
|
||||
}
|
||||
|
||||
$dutch = json_decode(file_get_contents(__DIR__.'/../../resources/lang/nl.json'), true);
|
||||
$missing = collect($english)->unique()->filter(fn (string $text) => $text !== '' && ! array_key_exists($text, $dutch))->values()->all();
|
||||
|
||||
expect($missing)->toBe([]);
|
||||
});
|
||||
|
||||
it('says the menu and the group form in the language of the app', function () {
|
||||
app()->setLocale('nl');
|
||||
$registry = app(ModuleRegistry::class);
|
||||
|
||||
expect(collect($registry->navigation())->pluck('label'))->toContain('Berichten', 'Groepen')
|
||||
->and(collect($registry->catalogue())->pluck('section'))->toContain('Inhoud van de site');
|
||||
|
||||
app()->setLocale('en');
|
||||
|
||||
expect(collect($registry->navigation())->pluck('label'))->toContain('Posts');
|
||||
});
|
||||
|
||||
it('lets the site override a text', function () {
|
||||
app()->setLocale('nl');
|
||||
$folder = sys_get_temp_dir().'/manager-lang-'.uniqid();
|
||||
mkdir($folder);
|
||||
file_put_contents($folder.'/nl.json', json_encode(['Posts' => 'Nieuws']));
|
||||
app('translator')->addJsonPath($folder);
|
||||
|
||||
expect(collect(app(ModuleRegistry::class)->navigation())->pluck('label'))->toContain('Nieuws');
|
||||
|
||||
unlink($folder.'/nl.json');
|
||||
rmdir($folder);
|
||||
});
|
||||
Reference in new issue
Block a user