Skip to content

Commit

Permalink
i18n: consider real path of APP to handle symlinks
Browse files Browse the repository at this point in the history
When extracting model validation messages, Reflection::getFileName is used
to obtain the the model filename. The returned value is actual physical
path and may differ to what APP is. Adding the realpath(APP) to $paths
variable allows str_replace() to correctly generate the correct value for
$occurences.
  • Loading branch information
rchavik committed Apr 24, 2012
1 parent 3f7e2f5 commit 3627512
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Cake/Console/Command/Task/ExtractTask.php
Expand Up @@ -463,6 +463,8 @@ protected function _processValidationRules($field, $rules, $file, $domain) {
* @return void
*/
protected function _buildFiles() {
$paths = $this->_paths;
$paths[] = realpath(APP) . DS;
foreach ($this->_translations as $domain => $translations) {
foreach ($translations as $msgid => $details) {
$plural = $details['msgid_plural'];
Expand All @@ -473,7 +475,7 @@ protected function _buildFiles() {
$occurrences[] = $file . ':' . implode(';', $lines);
}
$occurrences = implode("\n#: ", $occurrences);
$header = '#: ' . str_replace($this->_paths, '', $occurrences) . "\n";
$header = '#: ' . str_replace($paths, '', $occurrences) . "\n";

if ($plural === false) {
$sentence = "msgid \"{$msgid}\"\n";
Expand Down

0 comments on commit 3627512

Please sign in to comment.