From 2478d01dc5ecf917b20a6667e3b7214be768ae37 Mon Sep 17 00:00:00 2001 From: Thijs Kinkhorst <thijs@kinkhorst.com> Date: Wed, 12 Jan 2022 14:57:32 +0000 Subject: [PATCH] Support invocation for a specific module --- bin/get-translatable-strings | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/bin/get-translatable-strings b/bin/get-translatable-strings index 2aec4ffff..f48a82931 100755 --- a/bin/get-translatable-strings +++ b/bin/get-translatable-strings @@ -1,6 +1,17 @@ #!/usr/bin/php -q <?php - +/** + * Find translatable strings in Twig templates and the PHP library + * and merge them into the English PO file. + * + * It should be invoked from the root of a SimpleSAMLphp installation + * and can work on: + * - A specific module name given on the command line + * - The main product and the standard modules, when invoked with '--main'. + * + * It will search all Twig templates for occurences of the trans() + * function, and all PHP code under lib/ for the noop() function. + */ declare(strict_types=1); use SimpleSAML\Module; @@ -13,6 +24,17 @@ $baseDir = dirname(dirname(__FILE__)); // Add library autoloader require_once($baseDir . '/lib/_autoload.php'); +if($argc != 2) { + echo "Usage: $argv[0] (<module>|--main)\n"; + exit(1); +} + +if($argv[1] === '--main') { + $modules = ['', 'core', 'admin', 'cron', 'exampleauth', 'multiauth', 'saml']; +} else { + $modules = [$argv[1]]; +} + $transUtils = new Utils\Translate(); $sysUtils = new Utils\System(); $filesystem = new Filesystem(); @@ -23,7 +45,6 @@ $filesystem->remove($tempDirBase); $outputSuffix = '/locales/en/LC_MESSAGES'; -$modules = ['', 'core', 'admin', 'cron', 'exampleauth', 'multiauth', 'saml']; foreach($modules as $module) { $tempDir = $tempDirBase . "/" . $module; -- GitLab