Beispiel #1
0
 /**
  * Download all the translations from Loco. This will replace all the local files.
  * This is a quick method of getting all the latest translations and assets.
  */
 public function downloadAllTranslations()
 {
     $data = [];
     foreach ($this->projects as $name => $config) {
         if (empty($config['domains'])) {
             $this->getUrls($data, $config, $name, false);
         } else {
             foreach ($config['domains'] as $domain) {
                 $this->getUrls($data, $config, $domain, true);
             }
         }
     }
     $this->requestManager->downloadFiles($this->filesystemService, $data);
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $container = $this->getContainer();
     $requestManager = new RequestManager(new Client(), new GuzzleMessageFactory());
     $fileSystem = $container->get('happyr.translation.filesystem');
     $languages = $container->getParameter('enabled_locales');
     $domains = ['messages', 'validators', 'routes'];
     $query = ['key' => $container->getParameter('loco_api_key'), 'fallback' => $container->getParameter('default_locale'), 'index' => 'text', 'format' => 'symfony'];
     $uri = [];
     foreach ($languages as $language) {
         foreach ($domains as $domain) {
             $realQuery = $query;
             if ($domain === 'routes') {
                 unset($realQuery['index']);
             }
             $url = Loco::BASE_URL . 'export/locale/' . $language . '.xlf?' . http_build_query(array_merge($realQuery, ['filter' => $domain]));
             $uri[$url] = $domain . '.' . $language . '.xlf';
         }
     }
     $requestManager->downloadFiles($fileSystem, $uri);
     $output->writeln('Translations downloaded');
 }