Ejemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($this->validate($input, $output) !== TRUE) {
         return 1;
     }
     $catalogue = new MessageCatalogue($input->getOption('catalogue-language'));
     foreach ($this->scanDirs as $dir) {
         $output->writeln(sprintf('<info>Extracting %s</info>', $dir));
         $this->extractor->extract($dir, $catalogue);
     }
     $this->writer->writeTranslations($catalogue, $this->outputFormat, array('path' => $this->outputDir));
     $output->writeln('');
     $output->writeln(sprintf('<info>Catalogue was written to %s</info>', $this->outputDir));
     return 0;
 }
Ejemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($this->validate($input, $output) !== TRUE) {
         return 1;
     }
     $this->extractor->addExtractor('php', new PhpExtractor());
     $defaultLocale = null;
     foreach ($this->translator->getFallbackLocales() as $locale) {
         if (is_null($defaultLocale)) {
             $defaultLocale = $locale;
         }
         $catalogue = new MessageCatalogue($locale);
         $output->writeln(sprintf('<info>Locale %s</info>', $locale));
         foreach ($this->scanDirs as $dir) {
             $output->writeln(sprintf('<info>Extracting %s</info>', $dir));
             $this->extractor->extract($dir, $catalogue);
         }
     }
     $this->writer->writeTranslations($catalogue, $this->outputFormat, ['path' => $this->outputDir]);
     $output->writeln('');
     $output->writeln(sprintf('<info>Catalogue was written to %s</info>', $this->outputDir));
     $output->writeln('');
     $output->writeln(sprintf('<info>Zapisuji do DB</info>'));
     $toTranslate = (include dirname(__FILE__) . '/../../../../../temp/lang/messages.' . $defaultLocale . '.php');
     $texts = array('');
     foreach ($toTranslate as $translate) {
         $texts[] = $translate;
         $trans = $this->translates->where('text', $translate)->fetch();
         if (!$trans) {
             $this->translates->insert(array('text' => $translate));
         }
     }
     $this->translates->where('NOT text', $texts)->delete();
     $language = $this->languages->where('translate_locale', $defaultLocale)->fetch();
     $catalogue = new MessageCatalogue($language['translate_locale']);
     foreach ($this->translates->getAll() as $translate) {
         $translatesLocale = $translate->related('translate_locale')->where('language_id', $language['id'])->fetch();
         if ($translatesLocale) {
             $catalogue->set($translate['text'], $translatesLocale['translate']);
         } else {
             $catalogue->set($translate['text'], $translate['text']);
         }
     }
     $this->writer->writeTranslations($catalogue, 'neon', ['path' => $this->langDir]);
     return 0;
 }