feat: module-owned i18n with merge-at-boot translation loading
Each module can now ship its own i18n/ directory with translation files (default_de.json, default_en.json). At boot time, ModuleI18nLoader preloads core translations then merges module translations on top via Reflection into I18n::$strings — the t() helper stays unchanged. - Add i18nPath property to ModuleManifest - Add ModuleI18nLoader with Reflection-based preload - Extract 59 module-exclusive keys from core i18n into module files (notifications: 8, bookmarks: 41, addressbook: 10) - Expand TranslationKeysTest to scan modules/ and validate against merged core + module translations - Add ModuleI18nContractTest for per-module de/en parity and completeness Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
10
modules/notifications/i18n/default_de.json
Normal file
10
modules/notifications/i18n/default_de.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"Notifications": "Benachrichtigungen",
|
||||
"No notifications": "Keine Benachrichtigungen",
|
||||
"Mark all as read": "Alle als gelesen markieren",
|
||||
"Mark as read": "Als gelesen markieren",
|
||||
"Dismiss": "Verwerfen",
|
||||
"Action failed": "Aktion fehlgeschlagen",
|
||||
"New user: %s": "Neuer Benutzer: %s",
|
||||
"User deleted: %s": "Benutzer gelöscht: %s"
|
||||
}
|
||||
10
modules/notifications/i18n/default_en.json
Normal file
10
modules/notifications/i18n/default_en.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"Notifications": "Notifications",
|
||||
"No notifications": "No notifications",
|
||||
"Mark all as read": "Mark all as read",
|
||||
"Mark as read": "Mark as read",
|
||||
"Dismiss": "Dismiss",
|
||||
"Action failed": "Action failed",
|
||||
"New user: %s": "New user: %s",
|
||||
"User deleted: %s": "User deleted: %s"
|
||||
}
|
||||
115
modules/notifications/module.php
Normal file
115
modules/notifications/module.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Notifications module manifest.
|
||||
*
|
||||
* In-app notifications with bell icon, dropdown panel,
|
||||
* event-driven creation, and scheduled cleanup.
|
||||
*/
|
||||
return [
|
||||
'id' => 'notifications',
|
||||
'version' => '1.0.0',
|
||||
'enabled_by_default' => true,
|
||||
'load_order' => 15,
|
||||
'requires' => [],
|
||||
|
||||
'routes' => [
|
||||
['path' => 'notifications/list-data', 'target' => 'notifications/list-data'],
|
||||
['path' => 'notifications/mark-read-data', 'target' => 'notifications/mark-read-data'],
|
||||
['path' => 'notifications/delete-data', 'target' => 'notifications/delete-data'],
|
||||
['path' => 'notifications/unread-count-data', 'target' => 'notifications/unread-count-data'],
|
||||
],
|
||||
'public_paths' => [],
|
||||
|
||||
'container_registrars' => [
|
||||
\MintyPHP\Module\Notifications\NotificationsContainerRegistrar::class,
|
||||
],
|
||||
|
||||
'ui_slots' => [
|
||||
'topbar.right_item' => [
|
||||
[
|
||||
'key' => 'notifications-bell',
|
||||
'template' => 'templates/topbar-notification-bell.phtml',
|
||||
'permission' => 'notifications.view',
|
||||
'order' => 100,
|
||||
],
|
||||
],
|
||||
'layout.head_style' => [
|
||||
[
|
||||
'key' => 'notifications-topbar-style',
|
||||
'path' => 'modules/notifications/css/layout/app-topbar-notifications.css',
|
||||
'permission' => 'notifications.view',
|
||||
'order' => 100,
|
||||
],
|
||||
[
|
||||
'key' => 'notifications-dropdown-style',
|
||||
'path' => 'modules/notifications/css/components/app-notification-dropdown.css',
|
||||
'permission' => 'notifications.view',
|
||||
'order' => 101,
|
||||
],
|
||||
],
|
||||
'runtime.component' => [
|
||||
[
|
||||
'key' => 'notification-bell',
|
||||
'script' => 'modules/notifications/js/components/app-notification-bell.js',
|
||||
'export' => 'initNotificationBell',
|
||||
'scope' => 'global',
|
||||
'config_path' => 'components.notificationBell',
|
||||
'default_config' => [],
|
||||
'phase' => 'late',
|
||||
'permission' => 'notifications.view',
|
||||
'order' => 100,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'authorization_policies' => [
|
||||
\MintyPHP\Module\Notifications\NotificationsAuthorizationPolicy::class,
|
||||
],
|
||||
|
||||
'permissions' => [
|
||||
[
|
||||
'key' => 'notifications.view',
|
||||
'label' => 'Notifications: View',
|
||||
'description' => 'View and manage own notifications',
|
||||
],
|
||||
],
|
||||
|
||||
'event_listeners' => [
|
||||
'user.created' => [
|
||||
['class' => \MintyPHP\Module\Notifications\Listeners\UserCreatedNotificationListener::class, 'method' => 'handle'],
|
||||
],
|
||||
'user.deleted' => [
|
||||
['class' => \MintyPHP\Module\Notifications\Listeners\UserDeletedNotificationListener::class, 'method' => 'handle'],
|
||||
],
|
||||
],
|
||||
|
||||
'scheduler_jobs' => [
|
||||
[
|
||||
'job_key' => 'notifications_cleanup',
|
||||
'handler' => \MintyPHP\Module\Notifications\Handler\NotificationCleanupJobHandler::class,
|
||||
'label' => 'Notification cleanup',
|
||||
'description' => 'Purges read notifications older than 90 days',
|
||||
'default_enabled' => 1,
|
||||
'default_timezone' => 'UTC',
|
||||
'default_schedule_type' => 'daily',
|
||||
'default_schedule_interval' => 1,
|
||||
'default_schedule_time' => '04:00',
|
||||
'default_schedule_weekdays_csv' => null,
|
||||
'default_catchup_once' => 1,
|
||||
'allowed_schedule_types' => ['daily', 'weekly'],
|
||||
],
|
||||
],
|
||||
|
||||
'layout_context_providers' => [
|
||||
\MintyPHP\Module\Notifications\Providers\NotificationsLayoutProvider::class,
|
||||
],
|
||||
'session_providers' => [
|
||||
\MintyPHP\Module\Notifications\Providers\NotificationsSessionProvider::class,
|
||||
],
|
||||
|
||||
'search_resources' => [],
|
||||
'asset_groups' => [],
|
||||
'migrations_path' => 'db/updates',
|
||||
'i18n_path' => 'i18n',
|
||||
];
|
||||
Reference in New Issue
Block a user