From 69bb1e8c1b66195efc2e1ea534f9316f2566f0c1 Mon Sep 17 00:00:00 2001 From: Sam Wilson Date: Wed, 28 Feb 2024 21:38:58 +0800 Subject: [PATCH] Use rsvg-convert --accept-language rather than LANG env var (#727) Set the language used by rsvg-convert via the --accept-language CLI option rather than the LANG environment variable, as there seems to be an issue with the order of which env var gets used. More info: https://github.com/GNOME/librsvg/blob/main/rsvg-convert.rst#environment-variables Also update the built assets, so CI passes. Bug: T358305 --- composer.json | 2 +- src/Service/Renderer.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 61518125..7d092b05 100644 --- a/composer.json +++ b/composer.json @@ -87,7 +87,7 @@ "@generate-test-data" ], "generate-test-data": [ - "LANG=de rsvg-convert ./tests/data/Speech_bubbles.svg > ./tests/data/Speech_bubbles.png" + "rsvg-convert --accept-language=de ./tests/data/Speech_bubbles.svg > ./tests/data/Speech_bubbles.png" ], "lint": [ "composer validate", diff --git a/src/Service/Renderer.php b/src/Service/Renderer.php index 44af8cf4..cd750a3a 100644 --- a/src/Service/Renderer.php +++ b/src/Service/Renderer.php @@ -36,17 +36,17 @@ public function render(string $file, string $lang, ?string $outFile = null) : st { // Construct the command, using variables that will be escaped when it's run. $command = $this->rsvgCommand.' "$SVG"'; + if ('fallback' !== $lang) { + // Set the language to use from the SVG systemLanguage. + // If the fallback language is being requested, the OS's default will be + // used instead (as is done in MediaWiki). + $command .= " --accept-language=$lang"; + } if ($outFile) { // Redirect to output file if required. $command .= ' > "$PNG"'; } $process = Process::fromShellCommandline($command); - if ('fallback' !== $lang) { - // Set the LANG environment variable, which will be interpreted as the SVG - // systemLanguage. If the fallback language is being requested, the OS's default will be - // used instead (as is done in MediaWiki). - $process->setEnv(['LANG' => $lang]); - } $process->mustRun(null, ['SVG' => $file, 'PNG' => $outFile]); return $process->getOutput(); }