GettextTranslationHelper: Ensure that file source locations are relative

fixes #2684

(cherry picked from commit 91a315764c467bbb230cec1b54ba2466eb668eb9)
Signed-off-by: Eric Lippmann <eric.lippmann@icinga.com>
This commit is contained in:
Johannes Meyer 2017-01-25 09:56:21 +01:00 committed by Eric Lippmann
parent 59741ef993
commit 15fe0ad4e2

View File

@ -280,6 +280,7 @@ class GettextTranslationHelper
}
}
$this->updateHeader($this->tablePath);
$this->fixSourceLocations($this->tablePath);
}
/**
@ -400,12 +401,28 @@ class GettextTranslationHelper
'"Content-Type: text/plain; charset=' . $headerInfo['charset'] . '\n"',
'"Content-Transfer-Encoding: 8bit\n"',
'"Plural-Forms: nplurals=2; plural=(n != 1);\n"',
'"X-Poedit-Basepath: .\n"',
'"X-Poedit-SearchPath-0: .\n"',
''
)
) . PHP_EOL . substr($content, strpos($content, '#: '))
);
}
/**
* Adjust all absolute source file paths so that they're all relative to the catalog's location
*
* @param string $path
*/
protected function fixSourceLocations($path)
{
shell_exec(sprintf(
"sed -i 's;%s;../../../..;g' %s",
dirname($this->appDir),
$path
));
}
/**
* Create the file catalog
*