Skip to content

Commit

Permalink
GettextTranslationHelper: Ensure that file source locations are relative
Browse files Browse the repository at this point in the history
fixes #2684
  • Loading branch information
nilmerg committed Jan 25, 2017
1 parent 2f8d473 commit 91a3157
Showing 1 changed file with 17 additions and 0 deletions.
Expand Up @@ -280,6 +280,7 @@ private function updateTranslationTable()
}
}
$this->updateHeader($this->tablePath);
$this->fixSourceLocations($this->tablePath);
}

/**
Expand Down Expand Up @@ -400,12 +401,28 @@ private function updateHeader($path)
'"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
*
Expand Down

0 comments on commit 91a3157

Please sign in to comment.