mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
migration symfony 5 4 (#300)
* symfony 5.4 (diff dev) * symfony 5.4 (working) * symfony 5.4 (update autoload) * symfony 5.4 (remove swiftmailer mailer implementation) * symfony 5.4 (php doc and split Global accessor class) ### Impacted packages: composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
@@ -11,10 +11,14 @@
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Completion\CompletionInput;
|
||||
use Symfony\Component\Console\Completion\CompletionSuggestions;
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
@@ -22,6 +26,7 @@ use Symfony\Component\Translation\Catalogue\MergeOperation;
|
||||
use Symfony\Component\Translation\Catalogue\TargetOperation;
|
||||
use Symfony\Component\Translation\Extractor\ExtractorInterface;
|
||||
use Symfony\Component\Translation\MessageCatalogue;
|
||||
use Symfony\Component\Translation\MessageCatalogueInterface;
|
||||
use Symfony\Component\Translation\Reader\TranslationReaderInterface;
|
||||
use Symfony\Component\Translation\Writer\TranslationWriterInterface;
|
||||
|
||||
@@ -31,11 +36,20 @@ use Symfony\Component\Translation\Writer\TranslationWriterInterface;
|
||||
*
|
||||
* @author Michel Salib <michelsalib@hotmail.com>
|
||||
*
|
||||
* @final since version 3.4
|
||||
* @final
|
||||
*/
|
||||
class TranslationUpdateCommand extends ContainerAwareCommand
|
||||
class TranslationUpdateCommand extends Command
|
||||
{
|
||||
protected static $defaultName = 'translation:update';
|
||||
private const ASC = 'asc';
|
||||
private const DESC = 'desc';
|
||||
private const SORT_ORDERS = [self::ASC, self::DESC];
|
||||
private const FORMATS = [
|
||||
'xlf12' => ['xlf', '1.2'],
|
||||
'xlf20' => ['xlf', '2.0'],
|
||||
];
|
||||
|
||||
protected static $defaultName = 'translation:extract|translation:update';
|
||||
protected static $defaultDescription = 'Extract missing translations keys from code to translation files.';
|
||||
|
||||
private $writer;
|
||||
private $reader;
|
||||
@@ -43,25 +57,12 @@ class TranslationUpdateCommand extends ContainerAwareCommand
|
||||
private $defaultLocale;
|
||||
private $defaultTransPath;
|
||||
private $defaultViewsPath;
|
||||
private $transPaths;
|
||||
private $codePaths;
|
||||
private $enabledLocales;
|
||||
|
||||
/**
|
||||
* @param TranslationWriterInterface $writer
|
||||
* @param TranslationReaderInterface $reader
|
||||
* @param ExtractorInterface $extractor
|
||||
* @param string $defaultLocale
|
||||
* @param string $defaultTransPath
|
||||
* @param string $defaultViewsPath
|
||||
*/
|
||||
public function __construct($writer = null, TranslationReaderInterface $reader = null, ExtractorInterface $extractor = null, $defaultLocale = null, $defaultTransPath = null, $defaultViewsPath = null)
|
||||
public function __construct(TranslationWriterInterface $writer, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultLocale, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $codePaths = [], array $enabledLocales = [])
|
||||
{
|
||||
if (!$writer instanceof TranslationWriterInterface) {
|
||||
@trigger_error(sprintf('%s() expects an instance of "%s" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0.', __METHOD__, TranslationWriterInterface::class), \E_USER_DEPRECATED);
|
||||
|
||||
parent::__construct($writer);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->writer = $writer;
|
||||
@@ -70,6 +71,9 @@ class TranslationUpdateCommand extends ContainerAwareCommand
|
||||
$this->defaultLocale = $defaultLocale;
|
||||
$this->defaultTransPath = $defaultTransPath;
|
||||
$this->defaultViewsPath = $defaultViewsPath;
|
||||
$this->transPaths = $transPaths;
|
||||
$this->codePaths = $codePaths;
|
||||
$this->enabledLocales = $enabledLocales;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,29 +86,45 @@ class TranslationUpdateCommand extends ContainerAwareCommand
|
||||
new InputArgument('locale', InputArgument::REQUIRED, 'The locale'),
|
||||
new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages'),
|
||||
new InputOption('prefix', null, InputOption::VALUE_OPTIONAL, 'Override the default prefix', '__'),
|
||||
new InputOption('no-prefix', null, InputOption::VALUE_NONE, '[DEPRECATED] If set, no prefix is added to the translations'),
|
||||
new InputOption('output-format', null, InputOption::VALUE_OPTIONAL, 'Override the default output format', 'yaml'),
|
||||
new InputOption('output-format', null, InputOption::VALUE_OPTIONAL, 'Override the default output format (deprecated)'),
|
||||
new InputOption('format', null, InputOption::VALUE_OPTIONAL, 'Override the default output format', 'xlf12'),
|
||||
new InputOption('dump-messages', null, InputOption::VALUE_NONE, 'Should the messages be dumped in the console'),
|
||||
new InputOption('force', null, InputOption::VALUE_NONE, 'Should the update be done'),
|
||||
new InputOption('no-backup', null, InputOption::VALUE_NONE, 'Should backup be disabled'),
|
||||
new InputOption('force', null, InputOption::VALUE_NONE, 'Should the extract be done'),
|
||||
new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'),
|
||||
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to update'),
|
||||
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to extract'),
|
||||
new InputOption('xliff-version', null, InputOption::VALUE_OPTIONAL, 'Override the default xliff version (deprecated)'),
|
||||
new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically', 'asc'),
|
||||
new InputOption('as-tree', null, InputOption::VALUE_OPTIONAL, 'Dump the messages as a tree-like structure: The given value defines the level where to switch to inline YAML'),
|
||||
])
|
||||
->setDescription('Updates the translation file')
|
||||
->setDescription(self::$defaultDescription)
|
||||
->setHelp(<<<'EOF'
|
||||
The <info>%command.name%</info> command extracts translation strings from templates
|
||||
of a given bundle or the default translations directory. It can display them or merge the new ones into the translation files.
|
||||
of a given bundle or the default translations directory. It can display them or merge
|
||||
the new ones into the translation files.
|
||||
|
||||
When new translation strings are found it can automatically add a prefix to the translation
|
||||
message.
|
||||
|
||||
Example running against a Bundle (AcmeBundle)
|
||||
|
||||
<info>php %command.full_name% --dump-messages en AcmeBundle</info>
|
||||
<info>php %command.full_name% --force --prefix="new_" fr AcmeBundle</info>
|
||||
|
||||
Example running against default messages directory
|
||||
|
||||
<info>php %command.full_name% --dump-messages en</info>
|
||||
<info>php %command.full_name% --force --prefix="new_" fr</info>
|
||||
|
||||
You can sort the output with the <comment>--sort</> flag:
|
||||
|
||||
<info>php %command.full_name% --dump-messages --sort=asc en AcmeBundle</info>
|
||||
<info>php %command.full_name% --dump-messages --sort=desc fr</info>
|
||||
|
||||
You can dump a tree-like structure using the yaml format with <comment>--as-tree</> flag:
|
||||
|
||||
<info>php %command.full_name% --force --format=yaml --as-tree=3 en AcmeBundle</info>
|
||||
<info>php %command.full_name% --force --format=yaml --sort=asc --as-tree=3 fr</info>
|
||||
|
||||
EOF
|
||||
)
|
||||
;
|
||||
@@ -112,34 +132,14 @@ EOF
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* BC to be removed in 4.0
|
||||
*/
|
||||
public function isEnabled()
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
if (null !== $this->writer) {
|
||||
return parent::isEnabled();
|
||||
}
|
||||
if (!class_exists('Symfony\Component\Translation\Translator')) {
|
||||
return false;
|
||||
}
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
|
||||
|
||||
return parent::isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
// BC to be removed in 4.0
|
||||
if (null === $this->writer) {
|
||||
$this->writer = $this->getContainer()->get('translation.writer');
|
||||
$this->reader = $this->getContainer()->get('translation.reader');
|
||||
$this->extractor = $this->getContainer()->get('translation.extractor');
|
||||
$this->defaultLocale = $this->getContainer()->getParameter('kernel.default_locale');
|
||||
$this->defaultTransPath = $this->getContainer()->getParameter('translator.default_path');
|
||||
$this->defaultViewsPath = $this->getContainer()->getParameter('twig.default_path');
|
||||
if ('translation:update' === $input->getFirstArgument()) {
|
||||
$errorIo->caution('Command "translation:update" is deprecated since version 5.4 and will be removed in Symfony 6.0. Use "translation:extract" instead.');
|
||||
}
|
||||
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
@@ -152,47 +152,58 @@ EOF
|
||||
return 1;
|
||||
}
|
||||
|
||||
$format = $input->getOption('output-format') ?: $input->getOption('format');
|
||||
$xliffVersion = $input->getOption('xliff-version') ?? '1.2';
|
||||
|
||||
if ($input->getOption('xliff-version')) {
|
||||
$errorIo->warning(sprintf('The "--xliff-version" option is deprecated since version 5.3, use "--format=xlf%d" instead.', 10 * $xliffVersion));
|
||||
}
|
||||
|
||||
if ($input->getOption('output-format')) {
|
||||
$errorIo->warning(sprintf('The "--output-format" option is deprecated since version 5.3, use "--format=xlf%d" instead.', 10 * $xliffVersion));
|
||||
}
|
||||
|
||||
if (\in_array($format, array_keys(self::FORMATS), true)) {
|
||||
[$format, $xliffVersion] = self::FORMATS[$format];
|
||||
}
|
||||
|
||||
// check format
|
||||
$supportedFormats = $this->writer->getFormats();
|
||||
if (!\in_array($input->getOption('output-format'), $supportedFormats)) {
|
||||
$errorIo->error(['Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).'.']);
|
||||
if (!\in_array($format, $supportedFormats, true)) {
|
||||
$errorIo->error(['Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormats).', xlf12 and xlf20.']);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** @var KernelInterface $kernel */
|
||||
$kernel = $this->getApplication()->getKernel();
|
||||
|
||||
// Define Root Paths
|
||||
$transPaths = [$kernel->getRootDir().'/Resources/translations'];
|
||||
if ($this->defaultTransPath) {
|
||||
$transPaths[] = $this->defaultTransPath;
|
||||
}
|
||||
$viewsPaths = [$kernel->getRootDir().'/Resources/views'];
|
||||
if ($this->defaultViewsPath) {
|
||||
$viewsPaths[] = $this->defaultViewsPath;
|
||||
}
|
||||
$transPaths = $this->getRootTransPaths();
|
||||
$codePaths = $this->getRootCodePaths($kernel);
|
||||
|
||||
$currentName = 'default directory';
|
||||
|
||||
// Override with provided Bundle info
|
||||
if (null !== $input->getArgument('bundle')) {
|
||||
try {
|
||||
$foundBundle = $kernel->getBundle($input->getArgument('bundle'));
|
||||
$transPaths = [$foundBundle->getPath().'/Resources/translations'];
|
||||
$bundleDir = $foundBundle->getPath();
|
||||
$transPaths = [is_dir($bundleDir.'/Resources/translations') ? $bundleDir.'/Resources/translations' : $bundleDir.'/translations'];
|
||||
$codePaths = [is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundleDir.'/templates'];
|
||||
if ($this->defaultTransPath) {
|
||||
$transPaths[] = $this->defaultTransPath.'/'.$foundBundle->getName();
|
||||
$transPaths[] = $this->defaultTransPath;
|
||||
}
|
||||
$transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(), $foundBundle->getName());
|
||||
$viewsPaths = [$foundBundle->getPath().'/Resources/views'];
|
||||
if ($this->defaultViewsPath) {
|
||||
$viewsPaths[] = $this->defaultViewsPath.'/bundles/'.$foundBundle->getName();
|
||||
$codePaths[] = $this->defaultViewsPath;
|
||||
}
|
||||
$viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(), $foundBundle->getName());
|
||||
$currentName = $foundBundle->getName();
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
// such a bundle does not exist, so treat the argument as path
|
||||
$transPaths = [$input->getArgument('bundle').'/Resources/translations'];
|
||||
$viewsPaths = [$input->getArgument('bundle').'/Resources/views'];
|
||||
$currentName = $transPaths[0];
|
||||
$path = $input->getArgument('bundle');
|
||||
|
||||
$transPaths = [$path.'/translations'];
|
||||
$codePaths = [$path.'/templates'];
|
||||
|
||||
if (!is_dir($transPaths[0])) {
|
||||
throw new InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0]));
|
||||
@@ -203,30 +214,11 @@ EOF
|
||||
$io->title('Translation Messages Extractor and Dumper');
|
||||
$io->comment(sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale'), $currentName));
|
||||
|
||||
// load any messages from templates
|
||||
$extractedCatalogue = new MessageCatalogue($input->getArgument('locale'));
|
||||
$io->comment('Parsing templates...');
|
||||
$prefix = $input->getOption('prefix');
|
||||
// @deprecated since version 3.4, to be removed in 4.0 along with the --no-prefix option
|
||||
if ($input->getOption('no-prefix')) {
|
||||
@trigger_error('The "--no-prefix" option is deprecated since Symfony 3.4 and will be removed in 4.0. Use the "--prefix" option with an empty string as value instead.', \E_USER_DEPRECATED);
|
||||
$prefix = '';
|
||||
}
|
||||
$this->extractor->setPrefix($prefix);
|
||||
foreach ($viewsPaths as $path) {
|
||||
if (is_dir($path)) {
|
||||
$this->extractor->extract($path, $extractedCatalogue);
|
||||
}
|
||||
}
|
||||
$extractedCatalogue = $this->extractMessages($input->getArgument('locale'), $codePaths, $input->getOption('prefix'));
|
||||
|
||||
// load any existing messages from the translation files
|
||||
$currentCatalogue = new MessageCatalogue($input->getArgument('locale'));
|
||||
$io->comment('Loading translation files...');
|
||||
foreach ($transPaths as $path) {
|
||||
if (is_dir($path)) {
|
||||
$this->reader->read($path, $currentCatalogue);
|
||||
}
|
||||
}
|
||||
$currentCatalogue = $this->loadCurrentMessages($input->getArgument('locale'), $transPaths);
|
||||
|
||||
if (null !== $domain = $input->getOption('domain')) {
|
||||
$currentCatalogue = $this->filterCatalogue($currentCatalogue, $domain);
|
||||
@@ -242,11 +234,13 @@ EOF
|
||||
if (!\count($operation->getDomains())) {
|
||||
$errorIo->warning('No translation messages were found.');
|
||||
|
||||
return null;
|
||||
return 0;
|
||||
}
|
||||
|
||||
$resultMessage = 'Translation files were successfully updated';
|
||||
|
||||
$operation->moveMessagesToIntlDomainsIfPossible('new');
|
||||
|
||||
// show compiled list of messages
|
||||
if (true === $input->getOption('dump-messages')) {
|
||||
$extractedMessagesCount = 0;
|
||||
@@ -267,23 +261,34 @@ EOF
|
||||
|
||||
$domainMessagesCount = \count($list);
|
||||
|
||||
if ($sort = $input->getOption('sort')) {
|
||||
$sort = strtolower($sort);
|
||||
if (!\in_array($sort, self::SORT_ORDERS, true)) {
|
||||
$errorIo->error(['Wrong sort order', 'Supported formats are: '.implode(', ', self::SORT_ORDERS).'.']);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (self::DESC === $sort) {
|
||||
rsort($list);
|
||||
} else {
|
||||
sort($list);
|
||||
}
|
||||
}
|
||||
|
||||
$io->section(sprintf('Messages extracted for domain "<info>%s</info>" (%d message%s)', $domain, $domainMessagesCount, $domainMessagesCount > 1 ? 's' : ''));
|
||||
$io->listing($list);
|
||||
|
||||
$extractedMessagesCount += $domainMessagesCount;
|
||||
}
|
||||
|
||||
if ('xlf' == $input->getOption('output-format')) {
|
||||
$io->comment('Xliff output version is <info>1.2</info>');
|
||||
if ('xlf' === $format) {
|
||||
$io->comment(sprintf('Xliff output version is <info>%s</info>', $xliffVersion));
|
||||
}
|
||||
|
||||
$resultMessage = sprintf('%d message%s successfully extracted', $extractedMessagesCount, $extractedMessagesCount > 1 ? 's were' : ' was');
|
||||
}
|
||||
|
||||
if (true === $input->getOption('no-backup')) {
|
||||
$this->writer->disableBackup();
|
||||
}
|
||||
|
||||
// save the files
|
||||
if (true === $input->getOption('force')) {
|
||||
$io->comment('Writing files...');
|
||||
@@ -299,7 +304,7 @@ EOF
|
||||
$bundleTransPath = end($transPaths);
|
||||
}
|
||||
|
||||
$this->writer->write($operation->getResult(), $input->getOption('output-format'), ['path' => $bundleTransPath, 'default_locale' => $this->defaultLocale]);
|
||||
$this->writer->write($operation->getResult(), $format, ['path' => $bundleTransPath, 'default_locale' => $this->defaultLocale, 'xliff_version' => $xliffVersion, 'as_tree' => $input->getOption('as-tree'), 'inline' => $input->getOption('as-tree') ?? 0]);
|
||||
|
||||
if (true === $input->getOption('dump-messages')) {
|
||||
$resultMessage .= ' and translation files were updated';
|
||||
@@ -308,19 +313,87 @@ EOF
|
||||
|
||||
$io->success($resultMessage.'.');
|
||||
|
||||
return null;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function filterCatalogue(MessageCatalogue $catalogue, $domain)
|
||||
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
|
||||
{
|
||||
if ($input->mustSuggestArgumentValuesFor('locale')) {
|
||||
$suggestions->suggestValues($this->enabledLocales);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var KernelInterface $kernel */
|
||||
$kernel = $this->getApplication()->getKernel();
|
||||
if ($input->mustSuggestArgumentValuesFor('bundle')) {
|
||||
$bundles = [];
|
||||
|
||||
foreach ($kernel->getBundles() as $bundle) {
|
||||
$bundles[] = $bundle->getName();
|
||||
if ($bundle->getContainerExtension()) {
|
||||
$bundles[] = $bundle->getContainerExtension()->getAlias();
|
||||
}
|
||||
}
|
||||
|
||||
$suggestions->suggestValues($bundles);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($input->mustSuggestOptionValuesFor('format')) {
|
||||
$suggestions->suggestValues(array_merge(
|
||||
$this->writer->getFormats(),
|
||||
array_keys(self::FORMATS)
|
||||
));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($input->mustSuggestOptionValuesFor('domain') && $locale = $input->getArgument('locale')) {
|
||||
$extractedCatalogue = $this->extractMessages($locale, $this->getRootCodePaths($kernel), $input->getOption('prefix'));
|
||||
|
||||
$currentCatalogue = $this->loadCurrentMessages($locale, $this->getRootTransPaths());
|
||||
|
||||
// process catalogues
|
||||
$operation = $input->getOption('clean')
|
||||
? new TargetOperation($currentCatalogue, $extractedCatalogue)
|
||||
: new MergeOperation($currentCatalogue, $extractedCatalogue);
|
||||
|
||||
$suggestions->suggestValues($operation->getDomains());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($input->mustSuggestOptionValuesFor('sort')) {
|
||||
$suggestions->suggestValues(self::SORT_ORDERS);
|
||||
}
|
||||
}
|
||||
|
||||
private function filterCatalogue(MessageCatalogue $catalogue, string $domain): MessageCatalogue
|
||||
{
|
||||
$filteredCatalogue = new MessageCatalogue($catalogue->getLocale());
|
||||
|
||||
if ($messages = $catalogue->all($domain)) {
|
||||
// extract intl-icu messages only
|
||||
$intlDomain = $domain.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX;
|
||||
if ($intlMessages = $catalogue->all($intlDomain)) {
|
||||
$filteredCatalogue->add($intlMessages, $intlDomain);
|
||||
}
|
||||
|
||||
// extract all messages and subtract intl-icu messages
|
||||
if ($messages = array_diff($catalogue->all($domain), $intlMessages)) {
|
||||
$filteredCatalogue->add($messages, $domain);
|
||||
}
|
||||
foreach ($catalogue->getResources() as $resource) {
|
||||
$filteredCatalogue->addResource($resource);
|
||||
}
|
||||
|
||||
if ($metadata = $catalogue->getMetadata('', $intlDomain)) {
|
||||
foreach ($metadata as $k => $v) {
|
||||
$filteredCatalogue->setMetadata($k, $v, $intlDomain);
|
||||
}
|
||||
}
|
||||
|
||||
if ($metadata = $catalogue->getMetadata('', $domain)) {
|
||||
foreach ($metadata as $k => $v) {
|
||||
$filteredCatalogue->setMetadata($k, $v, $domain);
|
||||
@@ -329,4 +402,50 @@ EOF
|
||||
|
||||
return $filteredCatalogue;
|
||||
}
|
||||
|
||||
private function extractMessages(string $locale, array $transPaths, string $prefix): MessageCatalogue
|
||||
{
|
||||
$extractedCatalogue = new MessageCatalogue($locale);
|
||||
$this->extractor->setPrefix($prefix);
|
||||
foreach ($transPaths as $path) {
|
||||
if (is_dir($path) || is_file($path)) {
|
||||
$this->extractor->extract($path, $extractedCatalogue);
|
||||
}
|
||||
}
|
||||
|
||||
return $extractedCatalogue;
|
||||
}
|
||||
|
||||
private function loadCurrentMessages(string $locale, array $transPaths): MessageCatalogue
|
||||
{
|
||||
$currentCatalogue = new MessageCatalogue($locale);
|
||||
foreach ($transPaths as $path) {
|
||||
if (is_dir($path)) {
|
||||
$this->reader->read($path, $currentCatalogue);
|
||||
}
|
||||
}
|
||||
|
||||
return $currentCatalogue;
|
||||
}
|
||||
|
||||
private function getRootTransPaths(): array
|
||||
{
|
||||
$transPaths = $this->transPaths;
|
||||
if ($this->defaultTransPath) {
|
||||
$transPaths[] = $this->defaultTransPath;
|
||||
}
|
||||
|
||||
return $transPaths;
|
||||
}
|
||||
|
||||
private function getRootCodePaths(KernelInterface $kernel): array
|
||||
{
|
||||
$codePaths = $this->codePaths;
|
||||
$codePaths[] = $kernel->getProjectDir().'/src';
|
||||
if ($this->defaultViewsPath) {
|
||||
$codePaths[] = $this->defaultViewsPath;
|
||||
}
|
||||
|
||||
return $codePaths;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user