Skip to content

Commit

Permalink
Make it possible to show just the relative paths in the .pot files ge…
Browse files Browse the repository at this point in the history
…nerated by I18nShell
  • Loading branch information
Spriz committed Aug 7, 2018
1 parent 51f46ef commit ded811d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Shell/Task/ExtractTask.php
Expand Up @@ -49,6 +49,13 @@ class ExtractTask extends Shell
*/
protected $_merge = false;

/**
* Use relative paths in the pot files rather than full path
*
* @var bool
*/
protected $_relativePaths = false;

/**
* Current file being processed
*
Expand Down Expand Up @@ -233,6 +240,10 @@ public function main()
$this->_merge = strtolower($response) === 'y';
}

if (isset($this->params['relative-paths'])) {
$this->_relativePaths = !(strtolower($this->params['relative-paths']) === 'no');
}

if (empty($this->_files)) {
$this->_searchFiles();
}
Expand Down Expand Up @@ -321,6 +332,9 @@ public function getOptionParser()
])->addOption('merge', [
'help' => 'Merge all domain strings into the default.po file.',
'choices' => ['yes', 'no']
])->addOption('relative-paths', [
'help' => 'Use relative paths in the .pot file',
'choices' => ['yes', 'no']
])->addOption('output', [
'help' => 'Full path to output directory.'
])->addOption('files', [
Expand Down Expand Up @@ -447,6 +461,9 @@ protected function _parse($functionName, $map)
'file' => $this->_file,
'line' => $line,
];
if ($this->_relativePaths) {
$details['file'] = '.' . str_replace(ROOT, '', $details['file']);
}
if (isset($plural)) {
$details['msgid_plural'] = $plural;
}
Expand Down

0 comments on commit ded811d

Please sign in to comment.