From 64f03baa34f63cc9bc89566287d2b1ad005e9dbf Mon Sep 17 00:00:00 2001 From: codex Date: Sat, 7 Nov 2026 04:19:39 +0800 Subject: [PATCH] refactor(i18n): split copy manifest by page --- web/resources/user-copy/entry.php | 32 ++++++++++++++++++++++++++++ web/resources/user-copy/manifest.php | 19 +++++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 web/resources/user-copy/entry.php diff --git a/web/resources/user-copy/entry.php b/web/resources/user-copy/entry.php new file mode 100644 index 00000000..20a5c0f0 --- /dev/null +++ b/web/resources/user-copy/entry.php @@ -0,0 +1,32 @@ + $key, + 'scope' => $scope, + 'page' => $page, + 'kind' => $kind, + 'source' => $source, + 'format' => $parameters === [] ? 'plain_text' : 'icu', + 'parameters' => $parameters, + 'criticality' => $criticality, + 'allow_hide' => $allowHide, + 'toast_tone' => $toastTone, + ]; +}; diff --git a/web/resources/user-copy/manifest.php b/web/resources/user-copy/manifest.php index 8319c3f6..f65392ab 100644 --- a/web/resources/user-copy/manifest.php +++ b/web/resources/user-copy/manifest.php @@ -26,6 +26,21 @@ $common = static function ( ]; }; +$pageEntries = []; +$pageEntryFiles = glob(__DIR__ . '/entries/*.php'); +if (is_array($pageEntryFiles)) { + sort($pageEntryFiles, SORT_STRING); + foreach ($pageEntryFiles as $pageEntryFile) { + $fragment = require $pageEntryFile; + if (!is_array($fragment) || !array_is_list($fragment)) { + throw new RuntimeException( + '用户界面文案分片必须返回词条列表:' . $pageEntryFile + ); + } + array_push($pageEntries, ...$fragment); + } +} + return [ 'version' => 1, 'pages' => [ @@ -54,7 +69,7 @@ return [ 'user.tasks' => ['label' => '任务中心', 'scopes' => ['common', 'tasks']], 'user.tickets' => ['label' => '工单页', 'scopes' => ['common', 'tickets']], ], - 'entries' => [ + 'entries' => array_merge([ $common('common.shell.user_center', '用户中心', 'navigation'), $common('common.shell.sidebar.aria', '用户中心侧栏', 'aria_label'), $common('common.shell.navigation.aria', '用户中心主导航', 'aria_label'), @@ -162,5 +177,5 @@ return [ 'allow_hide' => false, 'toast_tone' => 'warning', ], - ], + ], $pageEntries), ];