From 545fe7da70462404bfc6c2ff10c95c818dd693ff Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 21 Jul 2016 15:35:52 +0200 Subject: [PATCH] Added translator and translations to GetVisitsCommand --- module/CLI/lang/es.mo | Bin 1238 -> 2199 bytes module/CLI/lang/es.po | 31 ++++++++++++++- module/CLI/src/Command/GetVisitsCommand.php | 42 +++++++++++++------- 3 files changed, 57 insertions(+), 16 deletions(-) diff --git a/module/CLI/lang/es.mo b/module/CLI/lang/es.mo index 08f58bd96006efffab0495d0cc27f145a5b7d370..2dcd57bcde8e004d9f701961ff46710a00bf1717 100644 GIT binary patch literal 2199 zcmbtU%WEV>9In;%HNI9s1o808g5qO)oEdQwI)rS@Ll-+8Li(d--p2Bz@ z<7Ww;mK?8#n^)0)GNx zOFRc7j{^zV1vY`f-Y39oz%PI}Dt-or*nb7y0{#gM@m_rx19%e{_CE!}jglkqBCOdj z*n1M=5sb&`)k{E7m3PBZuoZrw5szYo*uoECm3b3uw71ixv2>)3r=c|?m2$d(_1x&e zxtmRTFH=cY?xlt%roese$s2N+v7Ys6jQiy`B_`#2=ua5tj@(65I1VIvZpJPUAE?~3 zrIB*VyDMbb7gj4cXmmaypBcxbd5j}IlbTqkluFP4k-_BY34`;}`if&C5WU5kEk4o^ zc08Lpl2xE(oCn6vQdp)(!jH;VM3Hfw6EKLLH3>U+!iQ;@`101}7u;o1j+7qBT%}Fw z+X;=8&tNQ72M25!={B01Vu!=b0uPO6T1!(4R!l>FDw`>Lsd5;qk_T3}c__Uyn$9?U zS`E>Mue16i{X=OTm#e3TXk2zd%{mTMu9{%LUhFv}QV!r}i1Y(ad~`jH-ev1xHm2Py zSNcP0H(QO~c0XFTT>2A*RL9h5wXa64#i-M!_8W0$>D5-J6%Ix_9IP3A?zz`H)w!;8 zKI&VkT`s+`F*UkU4+=OF^;sUy&0}JBdvmvOqeuEK{FY`AI~5A*M_-N zdYO_eq{6T4^|zv>({sTbDiLjJGy?iErlo!58}CPT-vmE;hEwGc^ip%N*~VVA5WOiK z52epyYBn3ays$ElwooD$lOC2+x6)ar>T~5KO$#g3etG$nVAm8j;q}V1m@3z1^zZOw zY;5Yf%6Y_6Cx(}2UzN!@I+ixcdhjS}#pG;q?p8a-+tvqa&=7ZyZsO@PWioXC(AWeu zl6cXDmZ6~+#J}%TF6}@z>CO+gis?7y6G+)HG)X4V6KPj#f}yR+r^n!?WO|&cfq@^^ zo7wdPRl$(-si_u~th%#OeBqx<8YI9G>;aN%qQD$sD^O7bZ9C$y% zJFfPtRHhX*4nuuP?(TWlO9kQ}K+_{A5Ngx21@FsH^0KOsp;Cn)LEBcrQ?a2eCyAOK zYbYMXNQ#X)4{Fh=_JblJuPM}wPx4>I!ui>vp6w@5`&zaOw6KoCip{&PrGcoBd8k(K a#*x{_gN7!}m0YX^ed6Fm;RU^RwxZ}BpVR3L-{}@3`{`GJh_!IX7Wa+>67O(i%ovb?7(DTI$4)R qjmf}bb12Jg#>ooot0jCA6+(l26mk-a(i0UD6$*;-lT(Wmix>dt?Ib<` diff --git a/module/CLI/lang/es.po b/module/CLI/lang/es.po index 896f2965..595211c2 100644 --- a/module/CLI/lang/es.po +++ b/module/CLI/lang/es.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: Shlink 1.0\n" -"POT-Creation-Date: 2016-07-21 15:05+0200\n" -"PO-Revision-Date: 2016-07-21 15:08+0200\n" +"POT-Creation-Date: 2016-07-21 15:28+0200\n" +"PO-Revision-Date: 2016-07-21 15:32+0200\n" "Last-Translator: \n" "Language-Team: \n" "Language: es_ES\n" @@ -38,3 +38,30 @@ msgstr "URL generada:" #, php-format msgid "Provided URL \"%s\" is invalid. Try with a different one." msgstr "La URL proporcionada \"%s\" e inválida. Prueba con una diferente." + +msgid "Returns the detailed visits information for provided short code" +msgstr "Devuelve la información detallada de visitas para el código corto proporcionado" + +msgid "The short code which visits we want to get" +msgstr "El código corto del cual queremos obtener las visitas" + +msgid "Allows to filter visits, returning only those older than start date" +msgstr "Permite filtrar las visitas, devolviendo sólo aquellas más antiguas que startDate" + +msgid "Allows to filter visits, returning only those newer than end date" +msgstr "Permite filtrar las visitas, devolviendo sólo aquellas más nuevas que endDate" + +msgid "A short code was not provided. Which short code do you want to use?:" +msgstr "No se prporcionó un código corto. ¿Qué código corto deseas usar?" + +msgid "Referer" +msgstr "Origen" + +msgid "Date" +msgstr "Fecha" + +msgid "Remote Address" +msgstr "Dirección remota" + +msgid "User agent" +msgstr "Agente de usuario" diff --git a/module/CLI/src/Command/GetVisitsCommand.php b/module/CLI/src/Command/GetVisitsCommand.php index e7221e5e..c25ba27a 100644 --- a/module/CLI/src/Command/GetVisitsCommand.php +++ b/module/CLI/src/Command/GetVisitsCommand.php @@ -13,6 +13,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; +use Zend\I18n\Translator\TranslatorInterface; class GetVisitsCommand extends Command { @@ -20,35 +21,47 @@ class GetVisitsCommand extends Command * @var VisitsTrackerInterface */ private $visitsTracker; + /** + * @var TranslatorInterface + */ + private $translator; /** * GetVisitsCommand constructor. * @param VisitsTrackerInterface|VisitsTracker $visitsTracker + * @param TranslatorInterface $translator * - * @Inject({VisitsTracker::class}) + * @Inject({VisitsTracker::class, "translator"}) */ - public function __construct(VisitsTrackerInterface $visitsTracker) + public function __construct(VisitsTrackerInterface $visitsTracker, TranslatorInterface $translator) { - parent::__construct(null); $this->visitsTracker = $visitsTracker; + $this->translator = $translator; + parent::__construct(null); } public function configure() { $this->setName('shortcode:visits') - ->setDescription('Returns the detailed visits information for provided short code') - ->addArgument('shortCode', InputArgument::REQUIRED, 'The short code which visits we want to get') + ->setDescription( + $this->translator->translate('Returns the detailed visits information for provided short code') + ) + ->addArgument( + 'shortCode', + InputArgument::REQUIRED, + $this->translator->translate('The short code which visits we want to get') + ) ->addOption( 'startDate', 's', InputOption::VALUE_OPTIONAL, - 'Allows to filter visits, returning only those older than start date' + $this->translator->translate('Allows to filter visits, returning only those older than start date') ) ->addOption( 'endDate', 'e', InputOption::VALUE_OPTIONAL, - 'Allows to filter visits, returning only those newer than end date' + $this->translator->translate('Allows to filter visits, returning only those newer than end date') ); } @@ -61,9 +74,10 @@ class GetVisitsCommand extends Command /** @var QuestionHelper $helper */ $helper = $this->getHelper('question'); - $question = new Question( - 'A short code was not provided. Which short code do you want to use?: ' - ); + $question = new Question(sprintf( + '%s ', + $this->translator->translate('A short code was not provided. Which short code do you want to use?:') + )); $shortCode = $helper->ask($input, $output, $question); if (! empty($shortCode)) { @@ -80,10 +94,10 @@ class GetVisitsCommand extends Command $visits = $this->visitsTracker->info($shortCode, new DateRange($startDate, $endDate)); $table = new Table($output); $table->setHeaders([ - 'Referer', - 'Date', - 'Remote Address', - 'User agent', + $this->translator->translate('Referer'), + $this->translator->translate('Date'), + $this->translator->translate('Remote Address'), + $this->translator->translate('User agent'), ]); foreach ($visits as $row) {