public function write(MessageCatalogue $catalogue, $domain, $filePath, $format)
 {
     $newCatalogue = new MessageCatalogue();
     $newCatalogue->setLocale($catalogue->getLocale());
     foreach (array_keys($catalogue->getDomains()) as $catalogueDomainString) {
         if ($catalogue->getLocale() !== 'en' && $this->hasEnglishCatalogue($filePath)) {
             $englishCatalogue = $this->loadEnglishCatalogue($filePath, $domain, $format);
         }
         $domainMessageCollection = $catalogue->getDomain($catalogueDomainString);
         /** @var Message $message */
         foreach ($domainMessageCollection->all() as $message) {
             if ($message->getDomain() !== $domain) {
                 continue;
             }
             $newMessage = $this->makeXliffMessage($message);
             if ($message->getId() === $message->getSourceString()) {
                 if (isset($englishCatalogue)) {
                     try {
                         $newMessage->setDesc($englishCatalogue->get($message->getId(), $message->getDomain())->getLocaleString());
                     } catch (InvalidArgumentException $e) {
                         continue;
                     }
                 } else {
                     $newMessage->setDesc($message->getLocaleString());
                 }
             }
             $newCatalogue->add($newMessage);
         }
     }
     $this->innerFileWriter->write($newCatalogue, $domain, $filePath, $format);
 }
示例#2
0
 /**
  * @param \Twig_NodeInterface $node
  * @param \Twig_Environment $env
  * @return \Twig_NodeInterface
  */
 public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
 {
     $this->stack[] = $node;
     if ($node instanceof TransNode) {
         $id = $node->getNode('body')->getAttribute('data');
         $domain = 'messages';
         if (null !== ($domainNode = $node->getNode('domain'))) {
             $domain = $domainNode->getAttribute('value');
         }
         $message = new Message($id, $domain);
         $message->addSource($this->fileSourceFactory->create($this->file, $node->getLine()));
         $this->catalogue->add($message);
     } elseif ($node instanceof \Twig_Node_Expression_Filter) {
         $name = $node->getNode('filter')->getAttribute('value');
         if ('trans' === $name || 'transchoice' === $name) {
             $idNode = $node->getNode('node');
             if (!$idNode instanceof \Twig_Node_Expression_Constant) {
                 return $node;
                 // FIXME: see below
                 //                     throw new \RuntimeException(sprintf('Cannot infer translation id from node "%s". Please refactor to only translate constants.', get_class($idNode)));
             }
             $id = $idNode->getAttribute('value');
             $index = 'trans' === $name ? 1 : 2;
             $domain = 'messages';
             $arguments = $node->getNode('arguments');
             if ($arguments->hasNode($index)) {
                 $argument = $arguments->getNode($index);
                 if (!$argument instanceof \Twig_Node_Expression_Constant) {
                     return $node;
                     // FIXME: Throw exception if there is some way for the user to turn this off
                     //        on a case-by-case basis, similar to @Ignore in PHP
                 }
                 $domain = $argument->getAttribute('value');
             }
             $message = new Message($id, $domain);
             $message->addSource($this->fileSourceFactory->create($this->file, $node->getLine()));
             for ($i = count($this->stack) - 2; $i >= 0; $i -= 1) {
                 if (!$this->stack[$i] instanceof \Twig_Node_Expression_Filter) {
                     break;
                 }
                 $name = $this->stack[$i]->getNode('filter')->getAttribute('value');
                 if ('desc' === $name || 'meaning' === $name) {
                     $arguments = $this->stack[$i]->getNode('arguments');
                     if (!$arguments->hasNode(0)) {
                         throw new RuntimeException(sprintf('The "%s" filter requires exactly one argument, the description text.', $name));
                     }
                     $text = $arguments->getNode(0);
                     if (!$text instanceof \Twig_Node_Expression_Constant) {
                         throw new RuntimeException(sprintf('The first argument of the "%s" filter must be a constant expression, such as a string.', $name));
                     }
                     $message->{'set' . $name}($text->getAttribute('value'));
                 } elseif ('trans' === $name) {
                     break;
                 }
             }
             $this->catalogue->add($message);
         }
     }
     return $node;
 }
 public function extract()
 {
     $catalogue = new MessageCatalogue();
     $collection = $this->router instanceof I18nRouter ? $this->router->getOriginalRouteCollection() : $this->router->getRouteCollection();
     foreach ($collection->all() as $name => $route) {
         if ($this->routeExclusionStrategy->shouldExcludeRoute($name, $route)) {
             continue;
         }
         ///////////////////////////////////////
         // Begin customizations
         $meaning = "Route Controller and method: " . $route->getDefault('_controller');
         // set a default value
         // prefix with zikula module url if requested
         if ($route->hasDefault('_zkModule')) {
             $zkNoBundlePrefix = $route->getOption('zkNoBundlePrefix');
             if (!isset($zkNoBundlePrefix) || !$zkNoBundlePrefix) {
                 $meaning = "This is a route from the " . $route->getDefault('_zkModule') . "Bundle and will include a translated prefix.";
             }
         }
         // End customizations
         ///////////////////////////////////////
         $message = new Message($name, $this->domain);
         $message->setDesc($route->getPath());
         if (isset($meaning)) {
             $message->setMeaning($meaning);
         }
         $catalogue->add($message);
     }
     return $catalogue;
 }
 public function dump(MessageCatalogue $catalogue, $domain = 'messages', $filePath = null)
 {
     $structure = $catalogue->getDomain($domain)->all();
     if ($this->prettyPrint) {
         $tmpStructure = array();
         foreach ($structure as $id => $message) {
             $pointer =& $tmpStructure;
             $parts = explode('.', $id);
             // this algorithm only works if the messages are alphabetically
             // ordered, in particular it must be guaranteed that parent paths
             // are before sub-paths, e.g.
             // array_keys($structure) = array('foo.bar', 'foo.bar.baz')
             // but NOT: array_keys($structure) = array('foo.bar.baz', 'foo.bar')
             for ($i = 0, $c = count($parts); $i < $c; $i++) {
                 if ($i + 1 === $c) {
                     $pointer[$parts[$i]] = $message;
                     break;
                 }
                 if (!isset($pointer[$parts[$i]])) {
                     $pointer[$parts[$i]] = array();
                 }
                 if ($pointer[$parts[$i]] instanceof Message) {
                     $subPath = implode('.', array_slice($parts, $i));
                     $pointer[$subPath] = $message;
                     break;
                 }
                 $pointer =& $pointer[$parts[$i]];
             }
         }
         $structure = $tmpStructure;
         unset($tmpStructure);
     }
     return $this->dumpStructure($structure);
 }
 /**
  * Compares two message catalogues.
  *
  * @param MessageCatalogue $current
  * @param MessageCatalogue $new
  * @return ChangeSet
  */
 public function compare(MessageCatalogue $current, MessageCatalogue $new)
 {
     $newMessages = array();
     foreach ($new->getDomains() as $name => $domain) {
         if ($this->domains && !isset($this->domains[$name])) {
             continue;
         }
         if (isset($this->ignoredDomains[$name])) {
             continue;
         }
         foreach ($domain->all() as $message) {
             if ($current->has($message)) {
                 // FIXME: Compare what has changed
                 continue;
             }
             $newMessages[] = $message;
         }
     }
     $deletedMessages = array();
     foreach ($current->getDomains() as $name => $domain) {
         if ($this->domains && !isset($this->domains[$name])) {
             continue;
         }
         if (isset($this->ignoredDomains[$name])) {
             continue;
         }
         foreach ($domain->all() as $message) {
             if ($new->has($message)) {
                 continue;
             }
             $deletedMessages[] = $message;
         }
     }
     return new ChangeSet($newMessages, $deletedMessages);
 }
 /**
  * Get the translations
  *
  * @return MessageCatalogue
  */
 protected function getTranslations()
 {
     $catalogue = new MessageCatalogue();
     $labels = array();
     $entities = $this->getEntities();
     foreach ($entities as $entity) {
         $labels[] = $entity . '.label';
         $labels[] = $entity . '.show.title';
         $labels[] = $entity . '.edit.title';
         $labels[] = $entity . '.list.title';
         $labels[] = $entity . '.new.title';
         $labels[] = $entity . '.delete.title';
     }
     //avoid doublons
     $uniqueLabels = array_unique($labels);
     foreach ($uniqueLabels as $uniqueLabel) {
         $message = new Message($uniqueLabel, $this->domain);
         $catalogue->add($message);
     }
     if ($this->customizedFlash) {
         $flashLabels = $this->getFlashsLabels($entities);
         foreach ($flashLabels as $flashLabel) {
             $message = new Message($flashLabel, $this->domain);
             $catalogue->add($message);
         }
     }
     return $catalogue;
 }
    public function testCdataOutput()
    {
        $dumper = $this->getDumper();
        $catalogue = new MessageCatalogue();
        $catalogue->add(Message::create('foo')->setLocaleString('<bar>')->setDesc('<baz>'));
        $expected = <<<EOF
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
  <file source-language="en" target-language="" datatype="plaintext" original="not.available">
    <header>
      <tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
      <note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
    </header>
    <body>
      <trans-unit id="0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" resname="foo">
        <source><![CDATA[<baz>]]></source>
        <target state="new"><![CDATA[<bar>]]></target>
      </trans-unit>
    </body>
  </file>
</xliff>

EOF;
        $this->assertEquals($expected, $dumper->dump($catalogue, 'messages'));
    }
 public function testExtractConstraints()
 {
     $expected = new MessageCatalogue();
     $path = __DIR__ . '/Fixture/MyFormModel.php';
     $message = new Message('form.error.name_required', 'validators');
     $expected->add($message);
     $this->assertEquals($expected, $this->extract('MyFormModel.php'));
 }
 public function extract()
 {
     $catalogue = new MessageCatalogue();
     foreach ($this->fieldTypeCollectionFactory->getConcreteFieldTypesIdentifiers() as $fieldTypeIdentifier) {
         $catalogue->add(new Message($fieldTypeIdentifier . '.name', 'fieldtypes'));
     }
     return $catalogue;
 }
示例#10
0
 /**
  * @param mixed $resource
  * @param string $locale
  * @param string $domain
  * @return MessageCatalogue
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     $previous = libxml_use_internal_errors(true);
     if (false === ($doc = simplexml_load_file($resource))) {
         libxml_use_internal_errors($previous);
         $libxmlError = libxml_get_last_error();
         throw new RuntimeException(sprintf('Could not load XML-file "%s": %s', $resource, $libxmlError->message));
     }
     libxml_use_internal_errors($previous);
     $doc->registerXPathNamespace('xliff', 'urn:oasis:names:tc:xliff:document:1.2');
     $doc->registerXPathNamespace('jms', 'urn:jms:translation');
     $hasReferenceFiles = in_array('urn:jms:translation', $doc->getNamespaces(true));
     $catalogue = new MessageCatalogue();
     $catalogue->setLocale($locale);
     /** @var \SimpleXMLElement $trans */
     foreach ($doc->xpath('//xliff:trans-unit') as $trans) {
         $id = ($resName = (string) $trans->attributes()->resname) ? $resName : (string) $trans->source;
         /** @var Message $m */
         $m = Message::create($id, $domain)->setDesc((string) $trans->source)->setLocaleString((string) $trans->target);
         $m->setApproved($trans['approved'] == 'yes');
         if (isset($trans->target['state'])) {
             $m->setState((string) $trans->target['state']);
         }
         // Create closure
         $addNoteToMessage = function (Message $m, $note) {
             $m->addNote((string) $note, isset($note['from']) ? (string) $note['from'] : null);
         };
         // If the translation has a note
         if (isset($trans->note)) {
             // If we have more than one note. We can't use is_array becuase $trans->note is a \SimpleXmlElement
             if (count($trans->note) > 1) {
                 foreach ($trans->note as $note) {
                     $addNoteToMessage($m, $note);
                 }
             } else {
                 $addNoteToMessage($m, $trans->note);
             }
         }
         $catalogue->add($m);
         if ($hasReferenceFiles) {
             foreach ($trans->xpath('./jms:reference-file') as $file) {
                 $line = (string) $file->attributes()->line;
                 $column = (string) $file->attributes()->column;
                 $m->addSource(new FileSource((string) $file, $line ? (int) $line : null, $column ? (int) $column : null));
             }
         }
         if ($meaning = (string) $trans->attributes()->extradata) {
             if (0 === strpos($meaning, 'Meaning: ')) {
                 $meaning = substr($meaning, 9);
             }
             $m->setMeaning($meaning);
         }
         if (!($state = (string) $trans->target->attributes()->state) || 'new' !== $state) {
             $m->setNew(false);
         }
     }
     return $catalogue;
 }
 /**
  * Converts Symfony's message catalogue to the catalogue of this
  * bundle.
  *
  * @param mixed $resource
  * @param string $locale
  * @param string $domain
  * @return MessageCatalogue
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     $catalogue = new MessageCatalogue();
     $catalogue->setLocale($locale);
     foreach ($this->loader->load($resource, $locale, $domain)->all($domain) as $id => $message) {
         $catalogue->add(Message::create($id, $domain)->setLocaleString($message)->setNew(false));
     }
     return $catalogue;
 }
 public function testDumpStructureWithoutPrettyPrint()
 {
     $catalogue = new MessageCatalogue();
     $catalogue->setLocale('fr');
     $catalogue->add(new Message('foo.bar.baz'));
     $dumper = new PhpDumper();
     $dumper->setPrettyPrint(false);
     $this->assertEquals($this->getOutput('structure_wo_pretty_print'), $dumper->dump($catalogue, 'messages'));
 }
 public function extract()
 {
     $catalogue = new MessageCatalogue();
     foreach ($this->i18nLoader->extract($this->router->getRouteCollection()) as $name => $route) {
         $message = new Message($name, $this->domain);
         $message->setDesc($route->getPattern());
         $catalogue->add($message);
     }
     return $catalogue;
 }
 /**
  * Get the catalogue used for the structure tests
  *
  * @return MessageCatalogue
  */
 protected function getStructureCatalogue()
 {
     $catalogue = new MessageCatalogue();
     $catalogue->setLocale('en');
     $message = new Message('foo.bar.baz');
     $message->addSource(new FileSource('/a/b/c/foo/bar', 1, 2));
     $message->addSource(new FileSource('bar/baz', 1, 2));
     $catalogue->add($message);
     return $catalogue;
 }
 public function testPathWithSubPath()
 {
     $catalogue = new MessageCatalogue();
     $catalogue->setLocale('fr');
     $catalogue->add(new Message('foo.bar'));
     $catalogue->add(new Message('foo.bar.baz'));
     $dumper = $this->getDumper();
     $dumper->expects($this->once())->method('dumpStructure')->with(array('foo' => array('bar' => new Message('foo.bar'), 'bar.baz' => new Message('foo.bar.baz'))))->will($this->returnValue('foo'));
     $this->assertEquals('foo', $dumper->dump($catalogue, 'messages'));
 }
示例#16
0
 /**
  * @param \JMS\TranslationBundle\Model\MessageCatalogue $catalogue
  * @param string $domain
  * @param string $filePath
  * @param string $format
  * @throws \JMS\TranslationBundle\Exception\InvalidArgumentException
  */
 public function write(MessageCatalogue $catalogue, $domain, $filePath, $format)
 {
     if (!isset($this->dumpers[$format])) {
         throw new InvalidArgumentException(sprintf('The format "%s" is not supported.', $format));
     }
     // sort messages before dumping
     $catalogue->getDomain($domain)->sort(function ($a, $b) {
         return strcmp($a->getId(), $b->getId());
     });
     file_put_contents($filePath, $this->dumpers[$format]->dump($catalogue, $domain));
 }
 public function testExtractFormModel()
 {
     $expected = new MessageCatalogue();
     $path = __DIR__ . '/Fixture/MyFormModel.php';
     $message = new Message('form.label.choice.foo');
     $message->addSource(new FileSource($path, 13));
     $expected->add($message);
     $message = new Message('form.label.choice.bar');
     $message->addSource(new FileSource($path, 13));
     $expected->add($message);
     $this->assertEquals($expected, $this->extract('MyFormModel.php'));
 }
 public function testOnlySomeExtractorsEnabled()
 {
     $foo = $this->getMock('JMS\\TranslationBundle\\Translation\\ExtractorInterface');
     $foo->expects($this->never())->method('extract');
     $catalogue = new MessageCatalogue();
     $catalogue->add(new Message('foo'));
     $bar = $this->getMock('JMS\\TranslationBundle\\Translation\\ExtractorInterface');
     $bar->expects($this->once())->method('extract')->will($this->returnValue($catalogue));
     $manager = $this->getManager(null, array('foo' => $foo, 'bar' => $bar));
     $manager->setEnabledExtractors(array('bar' => true));
     $this->assertEquals($catalogue, $manager->extract());
 }
 public function testCompareWithMultipleDomains()
 {
     $current = new MessageCatalogue();
     $current->add(Message::create('foo')->setLocaleString('bar'));
     $current->add(Message::create('bar', 'routes')->setLocaleString('baz'));
     $new = new MessageCatalogue();
     $new->add(new Message('foo'));
     $new->add(new Message('bar'));
     $expected = new ChangeSet(array(new Message('bar')), array(Message::create('bar', 'routes')->setLocaleString('baz')));
     $comparator = new CatalogueComparator();
     $this->assertEquals($expected, $comparator->compare($current, $new));
 }
 public function testExtractValidationMessages()
 {
     $fileSourceFactory = $this->getFileSourceFactory();
     $fixtureSplInfo = new \SplFileInfo(__DIR__ . '/Fixture/MyEntity.php');
     $expected = new MessageCatalogue();
     $message = new Message('entity.default');
     $message->addSource($fileSourceFactory->create($fixtureSplInfo, 15));
     $expected->add($message);
     $message = new Message('entity.custom-domain', 'custom-domain');
     $message->addSource($fileSourceFactory->create($fixtureSplInfo, 22));
     $expected->add($message);
     $this->assertEquals($expected, $this->extract('MyEntity.php'));
 }
示例#21
0
 /**
  * @param \JMS\TranslationBundle\Model\MessageCatalogue $catalogue
  * @param string $domain
  * @param string $filePath
  * @param string $format
  * @throws \JMS\TranslationBundle\Exception\InvalidArgumentException
  */
 public function write(MessageCatalogue $catalogue, $domain, $filePath, $format)
 {
     if (!isset($this->dumpers[$format])) {
         $allowedFormats = array_keys($this->dumpers);
         $allowedFormatsString = join(',', $allowedFormats);
         throw new InvalidArgumentException(sprintf('The format "%s" is not supported. Allowed formats:%s', $format, $allowedFormatsString));
     }
     // sort messages before dumping
     $catalogue->getDomain($domain)->sort(function ($a, $b) {
         return strcmp($a->getId(), $b->getId());
     });
     file_put_contents($filePath, $this->dumpers[$format]->dump($catalogue, $domain));
 }
 public function testExtractTemplate()
 {
     $expected = new MessageCatalogue();
     $path = __DIR__ . '/Fixture/template.html.php';
     $message = new Message('foo.bar');
     $message->addSource(new FileSource($path, 1));
     $expected->add($message);
     $message = new Message('baz', 'moo');
     $message->setDesc('Foo Bar');
     $message->addSource(new FileSource($path, 3));
     $expected->add($message);
     $this->assertEquals($expected, $this->extract('template.html.php'));
 }
 public function testExtract()
 {
     $expected = new MessageCatalogue();
     $message = new Message('security.authentication_error.foo', 'authentication');
     $message->setDesc('%foo% is invalid.');
     $message->addSource(new FileSource(__DIR__ . '/Fixture/MyAuthException.php', 31));
     $expected->add($message);
     $message = new Message('security.authentication_error.bar', 'authentication');
     $message->setDesc('An authentication error occurred.');
     $message->addSource(new FileSource(__DIR__ . '/Fixture/MyAuthException.php', 35));
     $expected->add($message);
     $this->assertEquals($expected, $this->extract('MyAuthException.php'));
 }
示例#24
0
 public function testExtractTemplate()
 {
     $expected = new MessageCatalogue();
     $fileSourceFactory = $this->getFileSourceFactory();
     $fixtureSplInfo = new \SplFileInfo(__DIR__ . '/Fixture/template.html.php');
     $message = new Message('foo.bar');
     $message->addSource($fileSourceFactory->create($fixtureSplInfo, 1));
     $expected->add($message);
     $message = new Message('baz', 'moo');
     $message->setDesc('Foo Bar');
     $message->addSource($fileSourceFactory->create($fixtureSplInfo, 3));
     $expected->add($message);
     $this->assertEquals($expected, $this->extract('template.html.php'));
 }
 public function extract()
 {
     $catalogue = new MessageCatalogue();
     $collection = $this->router instanceof I18nRouter ? $this->router->getOriginalRouteCollection() : $this->router->getRouteCollection();
     foreach ($collection->all() as $name => $route) {
         if ($this->routeExclusionStrategy->shouldExcludeRoute($name, $route)) {
             continue;
         }
         $message = new Message($name, $this->domain);
         $message->setDesc($route->getPath());
         $catalogue->add($message);
     }
     return $catalogue;
 }
 public function testCatalogueIsSortedBeforeBeingDumped()
 {
     $dumper = $this->getMock('JMS\\TranslationBundle\\Translation\\Dumper\\DumperInterface');
     $self = $this;
     $dumper->expects($this->once())->method('dump')->will($this->returnCallback(function ($v) use($self) {
         $self->assertEquals(array('foo.bar', 'foo.bar.baz'), array_keys($v->getDomain('messages')->all()));
     }));
     $writer = new FileWriter(array('test' => $dumper));
     $catalogue = new MessageCatalogue();
     $catalogue->setLocale('fr');
     $catalogue->add(new Message('foo.bar.baz'));
     $catalogue->add(new Message('foo.bar'));
     $path = tempnam(sys_get_temp_dir(), 'filewriter');
     $writer->write($catalogue, 'messages', $path, 'test');
     @unlink($path);
 }
 /**
  * @param $dir
  * @param $targetLocale
  * @return \JMS\TranslationBundle\Model\MessageCatalogue
  */
 public function loadFromDirectory($dir, $targetLocale)
 {
     $files = FileUtils::findTranslationFiles($dir);
     $catalogue = new MessageCatalogue();
     $catalogue->setLocale($targetLocale);
     foreach ($files as $domain => $locales) {
         foreach ($locales as $locale => $data) {
             if ($locale !== $targetLocale) {
                 continue;
             }
             list($format, $file) = $data;
             $catalogue->merge($this->getLoader($format)->load($file, $locale, $domain));
         }
     }
     return $catalogue;
 }
示例#28
0
 private function getAllTranslations($locale)
 {
     $catalogue = new MessageCatalogue();
     $loader = $this->get('jms_translation.loader_manager');
     // load external resources, so current translations can be reused in the final translation
     foreach ($this->retrieveDirs() as $resource) {
         $catalogue->merge($loader->loadFromDirectory($resource, $locale));
     }
     $localesArray = array();
     foreach ($catalogue->getDomains() as $domain => $collection) {
         foreach ($collection->all() as $key => $translation) {
             $localesArray[$key] = $translation->getLocaleString();
         }
     }
     return $localesArray;
 }
 public function extract()
 {
     $catalogue = new MessageCatalogue();
     $locationClass = new \ReflectionClass(Location::class);
     $sortConstants = array_filter($locationClass->getConstants(), function ($key) {
         return strtolower(substr($key, 0, 5)) === 'sort_';
     }, ARRAY_FILTER_USE_KEY);
     foreach ($sortConstants as $sortId) {
         if (!isset($this->defaultTranslations[$sortId])) {
             continue;
         }
         $catalogue->add($this->createMessage('content_type.sort_field.' . $sortId, $this->defaultTranslations[$sortId], Location::class));
     }
     $catalogue->add($this->createMessage('content_type.sort_order.0', 'Descending', Location::class));
     $catalogue->add($this->createMessage('content_type.sort_order.1', 'Ascending', Location::class));
     return $catalogue;
 }
示例#30
0
 /**
  * @param Node $node
  * @return void
  */
 public function enterNode(Node $node)
 {
     if (!$node instanceof Node\Expr\MethodCall || !is_string($node->name) || !in_array(strtolower($node->name), array_map('strtolower', array_keys($this->methodsToExtractFrom)))) {
         $this->previousNode = $node;
         return;
     }
     $ignore = false;
     $desc = $meaning = null;
     if (null !== ($docComment = $this->getDocCommentForNode($node))) {
         if ($docComment instanceof Doc) {
             $docComment = $docComment->getText();
         }
         foreach ($this->docParser->parse($docComment, 'file ' . $this->file . ' near line ' . $node->getLine()) as $annot) {
             if ($annot instanceof Ignore) {
                 $ignore = true;
             } elseif ($annot instanceof Desc) {
                 $desc = $annot->text;
             } elseif ($annot instanceof Meaning) {
                 $meaning = $annot->text;
             }
         }
     }
     if (!$node->args[0]->value instanceof String_) {
         if ($ignore) {
             return;
         }
         $message = sprintf('Can only extract the translation id from a scalar string, but got "%s". Please refactor your code to make it extractable, or add the doc comment /** @Ignore */ to this code element (in %s on line %d).', get_class($node->args[0]->value), $this->file, $node->args[0]->value->getLine());
         if ($this->logger) {
             $this->logger->error($message);
             return;
         }
         throw new RuntimeException($message);
     }
     $id = $node->args[0]->value->value;
     $index = $this->methodsToExtractFrom[strtolower($node->name)];
     if (isset($node->args[$index])) {
         if (!$node->args[$index]->value instanceof String_) {
             if ($ignore) {
                 return;
             }
             $message = sprintf('Can only extract the translation domain from a scalar string, but got "%s". Please refactor your code to make it extractable, or add the doc comment /** @Ignore */ to this code element (in %s on line %d).', get_class($node->args[0]->value), $this->file, $node->args[0]->value->getLine());
             if ($this->logger) {
                 $this->logger->error($message);
                 return;
             }
             throw new RuntimeException($message);
         }
         $domain = $node->args[$index]->value->value;
     } else {
         $domain = 'messages';
     }
     $message = new Message($id, $domain);
     $message->setDesc($desc);
     $message->setMeaning($meaning);
     $message->addSource($this->fileSourceFactory->create($this->file, $node->getLine()));
     $this->catalogue->add($message);
 }