From 229def3a70fc4a67fcacdfb34bfee1d5442cce3d Mon Sep 17 00:00:00 2001 From: Dan Garner Date: Thu, 12 Sep 2024 12:27:50 +0100 Subject: [PATCH] Locale: fix error with translations generation script. relates to xibosignage/xibo#3500 --- bin/locale.php | 19 +++++++++---------- lib/Service/NullLogService.php | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/bin/locale.php b/bin/locale.php index 486725ba49..db6f2e92cd 100644 --- a/bin/locale.php +++ b/bin/locale.php @@ -1,7 +1,7 @@ addExtension(new TwigMessages(new Messages($storage))); foreach (glob(PROJECT_ROOT . '/views/*.twig') as $file) { - echo var_export($file, true) . PHP_EOL; - $view->getEnvironment()->load(str_replace(PROJECT_ROOT . '/views/', '', $file)); } @@ -137,7 +137,7 @@ function __($original) } if (!empty($setting->helpText)) { // replaces any single quote within the value with a backslash followed by a single quote - $helpText = addslashes($setting->helpText); + $helpText = addslashes(trim($setting->helpText)); $content .= 'echo __(\''.$helpText.'\');' . PHP_EOL; } @@ -153,7 +153,7 @@ function __($original) // Properties translation foreach ($module->properties as $property) { if (!empty($property->title)) { - $content .= 'echo __(\''.$property->title.'\');' . PHP_EOL; + $content .= 'echo __(\''.addslashes(trim($property->title)).'\');' . PHP_EOL; } if (!empty($property->helpText)) { // replaces any single quote within the value with a backslash followed by a single quote @@ -167,7 +167,7 @@ function __($original) // Property rule test message $message = $test->message; if (!empty($message)) { - $content .= 'echo __(\''.$message.'\');' . PHP_EOL; + $content .= 'echo __(\''.addslashes(trim($message)).'\');' . PHP_EOL; } } } @@ -190,11 +190,11 @@ function __($original) // Properties Translation foreach ($moduleTemplate->properties as $property) { if (!empty($property->title)) { - $content .= 'echo __(\''.$property->title.'\');' . PHP_EOL; + $content .= 'echo __(\''.addslashes(trim($property->title)).'\');' . PHP_EOL; } if (!empty($property->helpText)) { // replaces any single quote within the value with a backslash followed by a single quote - $helpText = addslashes($property->helpText); + $helpText = addslashes(trim($property->helpText)); $content .= 'echo __(\''.$helpText.'\');' . PHP_EOL; } @@ -219,6 +219,5 @@ function __($original) } } -$content .= '?>'; file_put_contents($file, $content); echo 'moduletranslate.file created and data written successfully.'; diff --git a/lib/Service/NullLogService.php b/lib/Service/NullLogService.php index 211badecce..35418c3d49 100644 --- a/lib/Service/NullLogService.php +++ b/lib/Service/NullLogService.php @@ -1,6 +1,6 @@