From 91a315764c467bbb230cec1b54ba2466eb668eb9 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 25 Jan 2017 09:56:21 +0100 Subject: [PATCH] GettextTranslationHelper: Ensure that file source locations are relative fixes #2684 --- .../Util/GettextTranslationHelper.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/translation/library/Translation/Util/GettextTranslationHelper.php b/modules/translation/library/Translation/Util/GettextTranslationHelper.php index 4d5fe9f2c..eb4b7438c 100644 --- a/modules/translation/library/Translation/Util/GettextTranslationHelper.php +++ b/modules/translation/library/Translation/Util/GettextTranslationHelper.php @@ -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 *