mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-27 16:26:37 +03:00
Added translator and translations to ProcessVisitsCommand
This commit is contained in:
parent
8e51b51cae
commit
6a05265a48
3 changed files with 44 additions and 11 deletions
Binary file not shown.
|
@ -1,8 +1,8 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Shlink 1.0\n"
|
"Project-Id-Version: Shlink 1.0\n"
|
||||||
"POT-Creation-Date: 2016-07-21 15:40+0200\n"
|
"POT-Creation-Date: 2016-07-21 15:48+0200\n"
|
||||||
"PO-Revision-Date: 2016-07-21 15:41+0200\n"
|
"PO-Revision-Date: 2016-07-21 15:49+0200\n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"Language: es_ES\n"
|
"Language: es_ES\n"
|
||||||
|
@ -96,3 +96,19 @@ msgstr "Has alcanzado la última página"
|
||||||
|
|
||||||
msgid "Continue with page"
|
msgid "Continue with page"
|
||||||
msgstr "Continuar con la página"
|
msgstr "Continuar con la página"
|
||||||
|
|
||||||
|
msgid "Processes visits where location is not set yet"
|
||||||
|
msgstr "Procesa las visitas donde la localización no ha sido establecida aún"
|
||||||
|
|
||||||
|
msgid "Processing IP"
|
||||||
|
msgstr "Procesando IP"
|
||||||
|
|
||||||
|
msgid "Ignored localhost address"
|
||||||
|
msgstr "Ignorada IP de localhost"
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "Address located at \"%s\""
|
||||||
|
msgstr "Dirección localizada en \"%s\""
|
||||||
|
|
||||||
|
msgid "Finished processing all IPs"
|
||||||
|
msgstr "Finalizado el procesado de todas las IPs"
|
||||||
|
|
|
@ -11,6 +11,7 @@ use Shlinkio\Shlink\Core\Service\VisitServiceInterface;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Zend\I18n\Translator\TranslatorInterface;
|
||||||
|
|
||||||
class ProcessVisitsCommand extends Command
|
class ProcessVisitsCommand extends Command
|
||||||
{
|
{
|
||||||
|
@ -24,25 +25,36 @@ class ProcessVisitsCommand extends Command
|
||||||
* @var IpLocationResolverInterface
|
* @var IpLocationResolverInterface
|
||||||
*/
|
*/
|
||||||
private $ipLocationResolver;
|
private $ipLocationResolver;
|
||||||
|
/**
|
||||||
|
* @var TranslatorInterface
|
||||||
|
*/
|
||||||
|
private $translator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ProcessVisitsCommand constructor.
|
* ProcessVisitsCommand constructor.
|
||||||
* @param VisitServiceInterface|VisitService $visitService
|
* @param VisitServiceInterface|VisitService $visitService
|
||||||
* @param IpLocationResolverInterface|IpLocationResolver $ipLocationResolver
|
* @param IpLocationResolverInterface|IpLocationResolver $ipLocationResolver
|
||||||
|
* @param TranslatorInterface $translator
|
||||||
*
|
*
|
||||||
* @Inject({VisitService::class, IpLocationResolver::class})
|
* @Inject({VisitService::class, IpLocationResolver::class, "translator"})
|
||||||
*/
|
*/
|
||||||
public function __construct(VisitServiceInterface $visitService, IpLocationResolverInterface $ipLocationResolver)
|
public function __construct(
|
||||||
{
|
VisitServiceInterface $visitService,
|
||||||
parent::__construct(null);
|
IpLocationResolverInterface $ipLocationResolver,
|
||||||
|
TranslatorInterface $translator
|
||||||
|
) {
|
||||||
$this->visitService = $visitService;
|
$this->visitService = $visitService;
|
||||||
$this->ipLocationResolver = $ipLocationResolver;
|
$this->ipLocationResolver = $ipLocationResolver;
|
||||||
|
$this->translator = $translator;
|
||||||
|
parent::__construct(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configure()
|
public function configure()
|
||||||
{
|
{
|
||||||
$this->setName('visit:process')
|
$this->setName('visit:process')
|
||||||
->setDescription('Processes visits where location is not set already');
|
->setDescription(
|
||||||
|
$this->translator->translate('Processes visits where location is not set yet')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execute(InputInterface $input, OutputInterface $output)
|
public function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
@ -51,9 +63,11 @@ class ProcessVisitsCommand extends Command
|
||||||
|
|
||||||
foreach ($visits as $visit) {
|
foreach ($visits as $visit) {
|
||||||
$ipAddr = $visit->getRemoteAddr();
|
$ipAddr = $visit->getRemoteAddr();
|
||||||
$output->write(sprintf('Processing IP <info>%s</info>', $ipAddr));
|
$output->write(sprintf('%s <info>%s</info>', $this->translator->translate('Processing IP'), $ipAddr));
|
||||||
if ($ipAddr === self::LOCALHOST) {
|
if ($ipAddr === self::LOCALHOST) {
|
||||||
$output->writeln(' (<comment>Ignored localhost address</comment>)');
|
$output->writeln(
|
||||||
|
sprintf(' (<comment>%s</comment>)', $this->translator->translate('Ignored localhost address'))
|
||||||
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,12 +77,15 @@ class ProcessVisitsCommand extends Command
|
||||||
$location->exchangeArray($result);
|
$location->exchangeArray($result);
|
||||||
$visit->setVisitLocation($location);
|
$visit->setVisitLocation($location);
|
||||||
$this->visitService->saveVisit($visit);
|
$this->visitService->saveVisit($visit);
|
||||||
$output->writeln(sprintf(' (Address located at "%s")', $location->getCityName()));
|
$output->writeln(sprintf(
|
||||||
|
' (' . $this->translator->translate('Address located at "%s"') . ')',
|
||||||
|
$location->getCityName()
|
||||||
|
));
|
||||||
} catch (WrongIpException $e) {
|
} catch (WrongIpException $e) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$output->writeln('Finished processing all IPs');
|
$output->writeln($this->translator->translate('Finished processing all IPs'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue