From 47a4fe584b4df0695e716f46e8414adbe8e50bbb Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 3 Oct 2026 20:38:56 +0000 Subject: [PATCH 1/5] Test all locale files; complete en.php and fix stale keys in de.php and oc.php Unit tests check the locale files (valid, no duplicate keys, UTF-8, date formats, all texts of the code in en.php); integration tests run the views with every locale and with a generated locale containing markup. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01UnF3JNHe2m9RQM1BRKdBMY --- locales/de.php | 7 +- locales/en.php | 44 ++++++ locales/oc.php | 6 +- tests/Integration/LocaleEscapingTest.php | 61 ++++++++ tests/Integration/LocaleTest.php | 101 ++++++++++++ tests/README.md | 6 +- tests/Unit/LocaleFilesTest.php | 186 +++++++++++++++++++++++ 7 files changed, 404 insertions(+), 7 deletions(-) create mode 100644 tests/Integration/LocaleEscapingTest.php create mode 100644 tests/Integration/LocaleTest.php create mode 100644 tests/Unit/LocaleFilesTest.php diff --git a/locales/de.php b/locales/de.php index 04d01d4..b977b53 100644 --- a/locales/de.php +++ b/locales/de.php @@ -30,9 +30,10 @@ 'Cancel' => 'Abbrechen', 'Saved' => 'Gespeichert', 'Log In' => 'Einloggen', - 'Log Out' => 'Ausloggen', + 'Log out' => 'Ausloggen', 'Password' => 'Passwort', 'Wrong password' => 'Falsches Passwort', + 'Invalid page name' => 'Ungültiger Seitenname', 'Title' => 'Titel', 'Image Description' => 'Bildbeschreibung', 'Name' => 'Name', @@ -60,10 +61,10 @@ 'Error renaming file' => 'Fehler beim Umbenennen der Datei', 'Sidebar file could not be found' => 'Seitenleisten-Datei nicht gefunden', 'Name of new page (restrictions in tip)' => 'Seitenname (Einschränkungen im Tip)', - "Character restrictions: '#' and '|' have a special meaning in page links, they will therefore be removed; also, characters '~', '/', '\\', ':', '|', '&' might cause trouble in filenames and are therefore replaced by '-'." => "Buchstaben-Beschränkungen: '#' und '|' haben eine spezielle Bedeutung in Links, sie werden deshalb entfernt. Weiters können die Zeichen '~', '/', '\\', ':', '|', '&' Probleme in Dateinamen verursachen, und werden deshalb durch einen Bindestrich '-' ersetzt.", + "Character restrictions: '#' and '|' have a special meaning in page links, they will therefore be removed; also, characters '~', '..', '\\', ':', '|', '&' might cause trouble in filenames and are therefore replaced by '-'." => "Buchstaben-Beschränkungen: '#' und '|' haben eine spezielle Bedeutung in Links, sie werden deshalb entfernt. Weiters können die Zeichen '~', '..', '\\', ':', '|', '&' Probleme in Dateinamen verursachen, und werden deshalb durch einen Bindestrich '-' ersetzt.", 'Image deleted' => 'Bild gelöscht', 'Image renamed' => 'Bild umbenannt', - 'Error deleting image' => 'Fehler beim Löschen des Bildes', + 'Error deleting image: ' => 'Fehler beim Löschen des Bildes: ', 'Restored unsaved draft from %s.' => 'Ungespeicherter Entwurf vom %s wiederhergestellt.', 'Warning: the page was changed since this draft was started.' => 'Achtung: Die Seite wurde geändert, seit dieser Entwurf begonnen wurde.', 'Discard draft' => 'Entwurf verwerfen', diff --git a/locales/en.php b/locales/en.php index c93362c..18eabfc 100644 --- a/locales/en.php +++ b/locales/en.php @@ -31,6 +31,50 @@ 'Restored unsaved draft from %s.' => 'Restored unsaved draft from %s.', 'Warning: the page was changed since this draft was started.' => 'Warning: the page was changed since this draft was started.', 'Discard draft' => 'Discard draft', + 'Close' => 'Close', + 'Markdown Syntax Helper' => 'Markdown Syntax Helper', + 'Header' => 'Header', + 'Emphasize' => 'Emphasize', + 'Bold' => 'Bold', + 'Formatting help' => 'Formatting help', + 'Wrong password' => 'Wrong password', + 'Password' => 'Password', + 'Invalid page name' => 'Invalid page name', + 'Created' => 'Created', + 'Creating new page since no page with given title exists!' => 'Creating new page since no page with given title exists!', + 'Character restrictions: \'#\' and \'|\' have a special meaning in page links, they will therefore be removed; also, characters \'~\', \'..\', \'\\\', \':\', \'|\', \'&\' might cause trouble in filenames and are therefore replaced by \'-\'.' => 'Character restrictions: \'#\' and \'|\' have a special meaning in page links, they will therefore be removed; also, characters \'~\', \'..\', \'\\\', \':\', \'|\', \'&\' might cause trouble in filenames and are therefore replaced by \'-\'.', + 'Name of new page (restrictions in tip)' => 'Name of new page (restrictions in tip)', + 'Shrink if larger than ' => 'Shrink if larger than ', + 'Pixels' => 'Pixels', + 'Total' => 'Total', + 'images' => 'images', + 'Usage' => 'Usage', + 'Action' => 'Action', + 'Used on page' => 'Used on page', + 'Rename' => 'Rename', + 'Delete' => 'Delete', + 'to' => 'to', + 'Removed' => 'Removed', + 'Renamed' => 'Renamed', + 'matches' => 'matches', + 'Updated links in the following pages:' => 'Updated links in the following pages:', + 'Error deleting file' => 'Error deleting file', + 'Error renaming file' => 'Error renaming file', + 'Image deleted' => 'Image deleted', + 'Image renamed' => 'Image renamed', + 'Updated images in the following pages:' => 'Updated images in the following pages:', + 'Error deleting image: ' => 'Error deleting image: ', + 'Error renaming image: ' => 'Error renaming image: ', + 'pages' => 'pages', + 'Name' => 'Name', + 'Modified' => 'Modified', + 'Size' => 'Size', + 'Create page' => 'Create page', + 'Log out' => 'Log out', + 'Sidebar file could not be found' => 'Sidebar file could not be found', + 'What links here:' => 'What links here:', + 'Image Description' => 'Image Description', + 'Show links here' => 'Show links here', // Override TITLE_DATE and TITLE_DATE_NO_TIME if set. 'date_format' => 'Y-m-d H:i:s', 'date_format_no_time' => 'Y-m-d', diff --git a/locales/oc.php b/locales/oc.php index 449a762..260d5b4 100644 --- a/locales/oc.php +++ b/locales/oc.php @@ -29,7 +29,7 @@ 'Cancel' => 'Anullar', 'Saved' => 'Salvat', 'Log In' => 'Connexion', - 'Log Out' => 'Desconnexion', + 'Log out' => 'Desconnexion', 'Password' => 'Senhal', 'Title' => 'Títol', 'Image Description' => 'Descripcion de l’imatge', @@ -57,9 +57,9 @@ 'Error renaming file' => 'Error en renomenant lo fichièr', 'Sidebar file could not be found' => 'Impossible de trobar la barra laterala', 'Name of new page (restrictions in tip)' => 'Nom de la pagina novèla (restriccion dins las astúcias)', - "Character restrictions: '#' and '|' have a special meaning in page links, they will therefore be removed; also, characters '~', '/', '\\', ':', '|', '&' might cause trouble in filenames and are therefore replaced by '-'." => "Restriccions dels caractèrs : '#' e '|' an una significacion especiala dins los ligams de pagina, seràn doncas tirats ; tanben, los caractèrs '~', '/', '\\', ':', '|', '&' que pòdon causar de problèmas dins los noms de fichièrs seràn remplaçat per '-'.", + "Character restrictions: '#' and '|' have a special meaning in page links, they will therefore be removed; also, characters '~', '..', '\\', ':', '|', '&' might cause trouble in filenames and are therefore replaced by '-'." => "Restriccions dels caractèrs : '#' e '|' an una significacion especiala dins los ligams de pagina, seràn doncas tirats ; tanben, los caractèrs '~', '..', '\\', ':', '|', '&' que pòdon causar de problèmas dins los noms de fichièrs seràn remplaçat per '-'.", 'Image deleted' => 'Imatge suprimit', - 'Error deleting image' => 'Error de supression de l’imatge', + 'Error deleting image: ' => 'Error de supression de l’imatge : ', // Override TITLE_DATE and TITLE_DATE_NO_TIME if set. 'date_format' => 'd/m/Y H:i:s', 'date_format_no_time' => 'd/m/Y', diff --git a/tests/Integration/LocaleEscapingTest.php b/tests/Integration/LocaleEscapingTest.php new file mode 100644 index 0000000..90d49e9 --- /dev/null +++ b/tests/Integration/LocaleEscapingTest.php @@ -0,0 +1,61 @@ +\'&'; + + protected function configOverrides(): array + { + return ['W2_LOCALE' => 'generated']; + } + + protected function setUp(): void + { + parent::setUp(); + $texts = []; + foreach (['All', 'New', 'Upload', 'Search', 'Home', 'Edit', 'Save', 'Cancel', 'Title', 'Close', 'Formatting help', 'Header', 'Bold', 'Emphasize'] as $key) { + $texts[$key] = self::PAYLOAD . $key; + } + file_put_contents($this->server->rootDir() . '/locales/generated.php', "server->rootDir() . '/locales/generated.php'); + parent::tearDown(); + } + + public function testTextsWithMarkupAndQuotesAreEscaped(): void + { + foreach (['/index.php', '/index.php?action=all', '/index.php?action=new', '/index.php?action=edit&page=Home'] as $url) { + $response = $this->http->get($url); + $this->assertSame(200, $response->status, $url); + $this->assertStringNotContainsString('