New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to show the relative paths in the .pot comments #12438
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
* | ||
|
@@ -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(); | ||
} | ||
|
@@ -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'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be a |
||
])->addOption('output', [ | ||
'help' => 'Full path to output directory.' | ||
])->addOption('files', [ | ||
|
@@ -447,6 +461,9 @@ protected function _parse($functionName, $map) | |
'file' => $this->_file, | ||
'line' => $line, | ||
]; | ||
if ($this->_relativePaths) { | ||
$details['file'] = '.' . str_replace(ROOT, '', $details['file']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If anyone has a better idea for the string replacing here - please just change it! Also using the Just tell me if I should change it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally would just use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I usually replace |
||
} | ||
if (isset($plural)) { | ||
$details['msgid_plural'] = $plural; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use
if (!$this->param('relative-paths')) {
here.