Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions Command/DeleteObsoleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class DeleteObsoleteCommand extends ContainerAwareCommand
{
/**
* @var ContainerInterface
*/
private $container;

protected function configure()
{
$this
Expand Down
42 changes: 42 additions & 0 deletions Command/DownloadCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/*
* This file is part of the PHP Translation package.
*
* (c) PHP Translation team <tobias.nyholm@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Translation\Bundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Translation\Bundle\Model\Configuration;
use Translation\Bundle\Service\StorageService;

/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class DownloadCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('translation:download')
->setDescription('Replace local messages with messages from remote')
->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default');
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$container = $this->getContainer();
$configName = $input->getArgument('configuration');
/** @var StorageService $storage */
$storage = $container->get('php_translation.storage.'.$configName);
$storage->download();
}
}
30 changes: 10 additions & 20 deletions Command/ExtractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Finder\Finder;
use Translation\Bundle\Model\Configuration;

/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class ExtractCommand extends ContainerAwareCommand
{
/**
* @var ContainerInterface
*/
private $container;

protected function configure()
{
$this
Expand All @@ -38,34 +35,27 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$container = $this->getContainer();
$configName = $input->getArgument('configuration');
$config = $container->get('php_translation.configuration_manager')->getConfiguration($configName);
$importer = $container->get('php_translation.importer');
$config = $container->get('php_translation.configuration_manager')
->getConfiguration($input->getArgument('configuration'));

$locales = [];
if ($inputLocale = $input->getArgument('locale')) {
$locales = [$inputLocale];
}

$catalogues = $container->get('php_translation.catalogue_fetcher')->getCatalogues($config, $locales);
$catalogues = $container->get('php_translation.catalogue_fetcher')
->getCatalogues($config, $locales);

$finder = $this->getConfiguredFinder($config);
$results = $importer->extractToCatalogues($finder, $catalogues, [
'blacklist_domains' => $config->getBlacklistDomains(),
'whitelist_domains' => $config->getWhitelistDomains(),
'project_root' => $config->getProjectRoot(),
]);

$writer = $container->get('translation.writer');
foreach ($results as $result) {
$writer->writeTranslations(
$result,
$config->getOutputFormat(),
[
'path' => $config->getOutputDir(),
'default_locale' => $container->getParameter('php_translation.default_locale'),
]
);
}
$container->get('php_translation.catalogue_writer')
->writeCatalogues($config, $results);
}

/**
Expand Down
42 changes: 42 additions & 0 deletions Command/SyncCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/*
* This file is part of the PHP Translation package.
*
* (c) PHP Translation team <tobias.nyholm@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Translation\Bundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Translation\Bundle\Model\Configuration;
use Translation\Bundle\Service\StorageService;

/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class SyncCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('translation:sync')
->setDescription('Sync the translations with the remote storage')
->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default');
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$container = $this->getContainer();
$configName = $input->getArgument('configuration');
/** @var StorageService $storage */
$storage = $container->get('php_translation.storage.'.$configName);
$storage->sync();
}
}