Skip to content

Commit

Permalink
Fix i18n collector
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Mooyman committed Oct 25, 2017
1 parent 9503c15 commit 27f2c55
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/Commands/Release/Branch.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ class Branch extends Release
self::NONE => self::NONE_DESCRIPTION,
];

/**
* Default branch option
*/
const DEFAULT_OPTION = self::AUTO;

protected function fire()
{
// Get arguments
Expand Down
15 changes: 15 additions & 0 deletions src/Model/Modules/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ public function getRelativeMainDirectory()
return substr($dir, strlen($base) + 1);
}

/**
* Get parameter to pass to i18n text collector
*
* @return string
*/
public function getI18nTextCollectorName()
{
$dir = $this->getRelativeMainDirectory();
// If short name has any slashes just use composer name instead
if (preg_match('#\w[\\/]\w#', $dir)) {
return $this->getName();
}
return $dir;
}

/**
* Determine if this project has a .tx configured
*
Expand Down
21 changes: 21 additions & 0 deletions src/Model/Modules/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SilverStripe\Cow\Model\Modules;

use BadMethodCallException;
use Generator;
use InvalidArgumentException;

Expand Down Expand Up @@ -110,4 +111,24 @@ public function getProject()
{
return $this;
}

/**
* Get path to sake executable
*
* @return string
*/
public function getSakePath()
{
$candidates = [
$this->getDirectory() . '/vendor/bin/sake', // New standard location
$this->getDirectory() . '/vendor/silverstripe/framework/sake',
$this->getDirectory() . '/framework/sake',
];
foreach ($candidates as $candidate) {
if (file_exists($candidate)) {
return $candidate;
}
}
throw new BadMethodCallException("sake bin could not be found in this project");
}
}
2 changes: 1 addition & 1 deletion src/Model/Release/LibraryRelease.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public function setChangelog($changelog)
* @param string $default Default value to get if no value found
* @return string
*/
public function getBranching($default = Branch::DEFAULT_OPTION)
public function getBranching($default = Branch::AUTO)
{
return $this->branching ?: $default;
}
Expand Down
5 changes: 3 additions & 2 deletions src/Steps/Release/UpdateTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,13 @@ protected function collectStrings(OutputInterface $output, $modules)
// Get code dirs for each module
$dirs = array();
foreach ($modules as $module) {
$dirs[] = $module->getRelativeMainDirectory();
$dirs[] = $module->getI18nTextCollectorName();
}

$sakeCommand = sprintf(
'(cd %s && ./framework/sake dev/tasks/i18nTextCollectorTask "flush=all" "merge=1" "module=%s")',
'(cd %s && %s dev/tasks/i18nTextCollectorTask "flush=all" "merge=1" "module=%s")',
$this->getProject()->getDirectory(),
$this->getProject()->getSakePath(),
implode(',', $dirs)
);
$this->runCommand($output, $sakeCommand, "Error encountered running i18nTextCollectorTask");
Expand Down

0 comments on commit 27f2c55

Please sign in to comment.