-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #532 from franmomu/apply_cs
Apply cs
- Loading branch information
Showing
78 changed files
with
778 additions
and
717 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright 2011 Johannes M. Schmitt <[email protected]> | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright 2011 Johannes M. Schmitt <[email protected]> | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright 2011 Johannes M. Schmitt <[email protected]> | ||
* | ||
|
@@ -30,9 +32,6 @@ final class Meaning | |
/** @var string @Required */ | ||
public $text; | ||
|
||
/** | ||
* Meaning constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
if (0 === func_num_args()) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright 2011 Johannes M. Schmitt <[email protected]> | ||
* | ||
|
@@ -18,14 +20,14 @@ | |
|
||
namespace JMS\TranslationBundle\Command; | ||
|
||
use JMS\TranslationBundle\Logger\OutputLogger; | ||
use JMS\TranslationBundle\Translation\ConfigBuilder; | ||
use JMS\TranslationBundle\Translation\ConfigFactory; | ||
use JMS\TranslationBundle\Translation\Updater; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use JMS\TranslationBundle\Logger\OutputLogger; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
|
@@ -82,14 +84,9 @@ protected function configure() | |
->addOption('output-format', null, InputOption::VALUE_REQUIRED, 'The output format that should be used (in most cases, it is better to change only the default-output-format).') | ||
->addOption('default-output-format', null, InputOption::VALUE_REQUIRED, 'The default output format (defaults to xlf).') | ||
->addOption('keep', null, InputOption::VALUE_NONE, 'Define if the updater service should keep the old translation (defaults to false).') | ||
->addOption('external-translations-dir', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Load external translation resources') | ||
; | ||
->addOption('external-translations-dir', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Load external translation resources'); | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$builder = $input->getOption('config') ? | ||
|
@@ -116,7 +113,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
$output->writeln(sprintf('Directories: <info>%s</info>', implode(', ', $config->getScanDirs()))); | ||
$output->writeln(sprintf('Excluded Directories: <info>%s</info>', $config->getExcludedDirs() ? implode(', ', $config->getExcludedDirs()) : '# none #')); | ||
$output->writeln(sprintf('Excluded Names: <info>%s</info>', $config->getExcludedNames() ? implode(', ', $config->getExcludedNames()) : '# none #')); | ||
$output->writeln(sprintf('Output-Format: <info>%s</info>', $config->getOutputFormat() ? $config->getOutputFormat() : '# whatever is present, if nothing then '.$config->getDefaultOutputFormat().' #')); | ||
$output->writeln(sprintf('Output-Format: <info>%s</info>', $config->getOutputFormat() ? $config->getOutputFormat() : '# whatever is present, if nothing then ' . $config->getDefaultOutputFormat() . ' #')); | ||
$output->writeln(sprintf('Custom Extractors: <info>%s</info>', $config->getEnabledExtractors() ? implode(', ', array_keys($config->getEnabledExtractors())) : '# none #')); | ||
$output->writeln('============================================================'); | ||
|
||
|
@@ -129,20 +126,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
if ($input->getOption('dry-run')) { | ||
$changeSet = $this->updater->getChangeSet($config); | ||
|
||
$output->writeln('Added Messages: '.count($changeSet->getAddedMessages())); | ||
$output->writeln('Added Messages: ' . count($changeSet->getAddedMessages())); | ||
if ($input->hasParameterOption('--verbose')) { | ||
foreach ($changeSet->getAddedMessages() as $message) { | ||
$output->writeln($message->getId(). '-> '.$message->getDesc()); | ||
$output->writeln($message->getId() . '-> ' . $message->getDesc()); | ||
} | ||
} | ||
|
||
if ($config->isKeepOldMessages()) { | ||
$output->writeln('Deleted Messages: # none as "Keep Old Translations" is true #'); | ||
} else { | ||
$output->writeln('Deleted Messages: '.count($changeSet->getDeletedMessages())); | ||
$output->writeln('Deleted Messages: ' . count($changeSet->getDeletedMessages())); | ||
if ($input->hasParameterOption('--verbose')) { | ||
foreach ($changeSet->getDeletedMessages() as $message) { | ||
$output->writeln($message->getId(). '-> '.$message->getDesc()); | ||
$output->writeln($message->getId() . '-> ' . $message->getDesc()); | ||
} | ||
} | ||
} | ||
|
@@ -158,10 +155,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
return 0; | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param ConfigBuilder $builder | ||
*/ | ||
private function updateWithInput(InputInterface $input, ConfigBuilder $builder) | ||
{ | ||
if ($bundle = $input->getOption('bundle')) { | ||
|
@@ -170,8 +163,8 @@ private function updateWithInput(InputInterface $input, ConfigBuilder $builder) | |
} | ||
|
||
$bundle = $this->getApplication()->getKernel()->getBundle($bundle); | ||
$builder->setTranslationsDir($bundle->getPath().'/Resources/translations'); | ||
$builder->setScanDirs(array($bundle->getPath())); | ||
$builder->setTranslationsDir($bundle->getPath() . '/Resources/translations'); | ||
$builder->setScanDirs([$bundle->getPath()]); | ||
} | ||
|
||
if ($dirs = $input->getOption('dir')) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright 2011 Johannes M. Schmitt <[email protected]> | ||
* | ||
|
@@ -18,11 +20,11 @@ | |
|
||
namespace JMS\TranslationBundle\Command; | ||
|
||
use JMS\TranslationBundle\Util\FileUtils; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use JMS\TranslationBundle\Util\FileUtils; | ||
|
||
/** | ||
* @author Fabien Potencier <[email protected]> | ||
|
@@ -62,14 +64,9 @@ protected function configure() | |
$this | ||
->setName('translation:list-resources') | ||
->setDescription('List translation resources available.') | ||
->addOption('files', null, InputOption::VALUE_OPTIONAL, 'Display only files') | ||
; | ||
->addOption('files', null, InputOption::VALUE_OPTIONAL, 'Display only files'); | ||
} | ||
|
||
/** | ||
* @param \Symfony\Component\Console\Input\InputInterface $input | ||
* @param \Symfony\Component\Console\Output\OutputInterface $output | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$directoriesToSearch = []; | ||
|
@@ -113,11 +110,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
|
||
/** | ||
* @param array $dirs | ||
* | ||
* @return array | ||
*/ | ||
private function retrieveFiles(array $dirs) | ||
{ | ||
$files = array(); | ||
$files = []; | ||
// Register translation resources | ||
foreach ($dirs as $dir) { | ||
foreach (FileUtils::findTranslationFiles($dir) as $catalogue => $locales) { | ||
|
@@ -138,21 +136,21 @@ private function retrieveFiles(array $dirs) | |
private function retrieveDirs() | ||
{ | ||
// Discover translation directories | ||
$dirs = array(); | ||
$dirs = []; | ||
foreach ($this->bundles as $bundle) { | ||
$reflection = new \ReflectionClass($bundle); | ||
if (is_dir($dir = dirname($reflection->getFilename()).'/Resources/translations')) { | ||
if (is_dir($dir = dirname($reflection->getFilename()) . '/Resources/translations')) { | ||
$dirs[] = $dir; | ||
} | ||
} | ||
|
||
// TODO: Remove this block when dropping support of Symfony 4 | ||
if ($this->rootDir !== null && | ||
is_dir($dir = $this->rootDir.'/Resources/translations')) { | ||
is_dir($dir = $this->rootDir . '/Resources/translations')) { | ||
$dirs[] = $dir; | ||
} | ||
|
||
if (is_dir($dir = $this->projectDir.'/translations')) { | ||
if (is_dir($dir = $this->projectDir . '/translations')) { | ||
$dirs[] = $dir; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright 2011 Johannes M. Schmitt <[email protected]> | ||
* | ||
|
@@ -21,15 +23,15 @@ | |
use JMS\TranslationBundle\Exception\RuntimeException; | ||
use JMS\TranslationBundle\Translation\ConfigFactory; | ||
use JMS\TranslationBundle\Translation\Updater; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use JMS\TranslationBundle\Util\FileUtils; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
/** | ||
* @Route("/api") | ||
* | ||
* @author Johannes M. Schmitt <[email protected]> | ||
* | ||
* @Route("/api") | ||
*/ | ||
class ApiController | ||
{ | ||
|
@@ -43,30 +45,25 @@ class ApiController | |
*/ | ||
private $updater; | ||
|
||
/** | ||
* ApiController constructor. | ||
* | ||
* @param ConfigFactory $configFactory | ||
* @param Updater $updater | ||
*/ | ||
public function __construct(ConfigFactory $configFactory, Updater $updater) | ||
{ | ||
$this->configFactory = $configFactory; | ||
$this->updater = $updater; | ||
} | ||
|
||
/** | ||
* @Route("/configs/{config}/domains/{domain}/locales/{locale}/messages", | ||
* methods={"PUT"}, | ||
* name="jms_translation_update_message", | ||
* defaults = {"id" = null}, | ||
* options = {"i18n" = false}) | ||
* @param Request $request | ||
* @param string $config | ||
* @param string $domain | ||
* @param string $locale | ||
* | ||
* @return Response | ||
* | ||
* @Route("/configs/{config}/domains/{domain}/locales/{locale}/messages", | ||
* methods={"PUT"}, | ||
* name="jms_translation_update_message", | ||
* defaults = {"id" = null}, | ||
* options = {"i18n" = false}) | ||
*/ | ||
public function updateMessageAction(Request $request, $config, $domain, $locale) | ||
{ | ||
|
@@ -86,7 +83,11 @@ public function updateMessageAction(Request $request, $config, $domain, $locale) | |
[$format, $file] = $files[$domain][$locale]; | ||
|
||
$this->updater->updateTranslation( | ||
$file, $format, $domain, $locale, $id, | ||
$file->getPathname(), | ||
$format, | ||
$domain, | ||
$locale, | ||
$id, | ||
$request->request->get('message') | ||
); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright 2011 Johannes M. Schmitt <[email protected]> | ||
* | ||
|
@@ -48,12 +50,6 @@ class TranslateController | |
*/ | ||
private $sourceLanguage; | ||
|
||
/** | ||
* TranslateController constructor. | ||
* | ||
* @param ConfigFactory $configFactory | ||
* @param LoaderManager $loader | ||
*/ | ||
public function __construct(ConfigFactory $configFactory, LoaderManager $loader) | ||
{ | ||
$this->configFactory = $configFactory; | ||
|
@@ -69,10 +65,12 @@ public function setSourceLanguage($lang) | |
} | ||
|
||
/** | ||
* @Route("/", name="jms_translation_index", options = {"i18n" = false}) | ||
* @Template("@JMSTranslation/Translate/index.html.twig") | ||
* @param Request $request | ||
* | ||
* @return array | ||
* | ||
* @Route("/", name="jms_translation_index", options = {"i18n" = false}) | ||
* @Template("@JMSTranslation/Translate/index.html.twig") | ||
*/ | ||
public function indexAction(Request $request) | ||
{ | ||
|
@@ -111,7 +109,7 @@ public function indexAction(Request $request) | |
// create alternative messages | ||
// TODO: We should probably also add these to the XLIFF file for external translators, | ||
// and the specification already supports it | ||
$alternativeMessages = array(); | ||
$alternativeMessages = []; | ||
foreach ($locales as $otherLocale) { | ||
if ($locale === $otherLocale) { | ||
continue; | ||
|
@@ -128,7 +126,7 @@ public function indexAction(Request $request) | |
} | ||
} | ||
|
||
$newMessages = $existingMessages = array(); | ||
$newMessages = $existingMessages = []; | ||
foreach ($catalogue->getDomain($domain)->all() as $id => $message) { | ||
if ($message->isNew()) { | ||
$newMessages[$id] = $message; | ||
|
@@ -138,7 +136,7 @@ public function indexAction(Request $request) | |
$existingMessages[$id] = $message; | ||
} | ||
|
||
return array( | ||
return [ | ||
'selectedConfig' => $config, | ||
'configs' => $configs, | ||
'selectedDomain' => $domain, | ||
|
@@ -149,9 +147,9 @@ public function indexAction(Request $request) | |
'newMessages' => $newMessages, | ||
'existingMessages' => $existingMessages, | ||
'alternativeMessages' => $alternativeMessages, | ||
'isWriteable' => is_writeable($files[$domain][$locale][1]), | ||
'isWriteable' => is_writable((string) $files[$domain][$locale][1]), | ||
'file' => (string) $files[$domain][$locale][1], | ||
'sourceLanguage' => $this->sourceLanguage, | ||
); | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright 2011 Johannes M. Schmitt <[email protected]> | ||
* | ||
|
@@ -18,8 +20,8 @@ | |
|
||
namespace JMS\TranslationBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
class IntegrationPass implements CompilerPassInterface | ||
{ | ||
|
Oops, something went wrong.