Skip to content

Commit

Permalink
Use rsvg-convert --accept-language rather than LANG env var (#727)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
samwilson authored Feb 28, 2024
1 parent 93ad0ba commit 69bb1e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions src/Service/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 69bb1e8

Please sign in to comment.