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(); }