diff options
author | sgiehl <stefan@piwik.org> | 2015-04-13 00:14:19 +0300 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2015-04-21 22:41:20 +0300 |
commit | 78abf42c41259d6d4b97c1a5130aa0df911a500f (patch) | |
tree | 7d6e4c55caa420e93fff341fc553c5317206c59a /plugins | |
parent | 6f1c8004bf7dd3a98b9d47c72831294c7c9a64c7 (diff) |
refs #7567 - improved usage of transifex api
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/LanguagesManager/Commands/FetchFromTransifex.php | 19 | ||||
-rw-r--r-- | plugins/LanguagesManager/Commands/Update.php | 4 |
2 files changed, 20 insertions, 3 deletions
diff --git a/plugins/LanguagesManager/Commands/FetchFromTransifex.php b/plugins/LanguagesManager/Commands/FetchFromTransifex.php index aac1d10b2b..e6df2bfde0 100644 --- a/plugins/LanguagesManager/Commands/FetchFromTransifex.php +++ b/plugins/LanguagesManager/Commands/FetchFromTransifex.php @@ -41,12 +41,27 @@ class FetchFromTransifex extends TranslationBase $resource = 'piwik-'. ($plugin ? 'plugin-'.strtolower($plugin) : 'base'); - $output->writeln("Fetching translations from Transifex for resource $resource"); - $transifexApi = new API($username, $password); + // remove all existing translation files in download path + $files = glob($this->getDownloadPath() . DIRECTORY_SEPARATOR . '*.json'); + array_map('unlink', $files); + + if (!$transifexApi->resourceExists($resource)) { + $output->writeln("Skipping resource $resource as it doesn't exist on Transifex"); + return; + } + + $output->writeln("Fetching translations from Transifex for resource $resource"); + $languages = $transifexApi->getAvailableLanguageCodes(); + if (!empty($plugin)) { + $languages = array_filter($languages, function($language) { + return \Piwik\Plugins\LanguagesManager\API::getInstance()->isLanguageAvailable(str_replace('_', '-', strtolower($language))); + }); + } + /** @var ProgressHelper $progress */ $progress = $this->getHelperSet()->get('progress'); diff --git a/plugins/LanguagesManager/Commands/Update.php b/plugins/LanguagesManager/Commands/Update.php index f09188e83a..883a214b14 100644 --- a/plugins/LanguagesManager/Commands/Update.php +++ b/plugins/LanguagesManager/Commands/Update.php @@ -33,6 +33,8 @@ class Update extends TranslationBase protected function execute(InputInterface $input, OutputInterface $output) { + $start = microtime(true); + /** @var DialogHelper $dialog */ $dialog = $this->getHelperSet()->get('dialog'); @@ -109,7 +111,7 @@ class Update extends TranslationBase $progress->finish(); } - $output->writeln("Finished."); + $output->writeln("Finished in " . round(microtime(true)-$start, 3) . "s"); } /** |