diff options
author | sgiehl <stefan@piwik.org> | 2015-04-17 01:08:12 +0300 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2015-04-21 22:41:20 +0300 |
commit | 1ae88c88edd63fcaa49d17d22afec895d809a456 (patch) | |
tree | bab472f4eacd5cf5b3395fb4c902e3622923f522 /plugins/LanguagesManager/Commands/Update.php | |
parent | 3c8fd3186e17fa18a95fbfb18bb546839bc5c937 (diff) |
refs #7567 - use transifex statistics api and git modification time to determine which resources needs to be updated
Diffstat (limited to 'plugins/LanguagesManager/Commands/Update.php')
-rw-r--r-- | plugins/LanguagesManager/Commands/Update.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/LanguagesManager/Commands/Update.php b/plugins/LanguagesManager/Commands/Update.php index 883a214b14..ea208a2743 100644 --- a/plugins/LanguagesManager/Commands/Update.php +++ b/plugins/LanguagesManager/Commands/Update.php @@ -61,11 +61,18 @@ class Update extends TranslationBase foreach ($pluginList as $plugin) { + $output->writeln(""); + // fetch base or specific plugin $this->fetchTranslations($input, $output, $plugin); $files = _glob(FetchFromTransifex::getDownloadPath() . DIRECTORY_SEPARATOR . '*.json'); + if (count($files) == 0) { + $output->writeln("No translation updates available! Skipped."); + continue; + } + /** @var ProgressHelper $progress */ $progress = $this->getHelperSet()->get('progress'); @@ -149,6 +156,20 @@ class Update extends TranslationBase protected function fetchTranslations($input, $output, $plugin) { + $lastModDate = 0; + try { + // try to find the language file (of given plugin) with the newest modification date in git log + $path = ($plugin ? 'plugins/' . $plugin . '/' : '') . 'lang'; + $files = explode("\n", trim(shell_exec('git ls-tree -r --name-only HEAD ' . $path))); + + foreach ($files as $file) { + $fileModDate = shell_exec('git log -1 --format="%at" -- ' . $file); + if (basename($file) != 'en.json' && ($lastModDate != 0 || $fileModDate > $lastModDate)) { + $lastModDate = $fileModDate; + } + } + } catch (\Exception $e) {} + $command = $this->getApplication()->find('translations:fetch'); $arguments = array( 'command' => 'translations:fetch', @@ -156,6 +177,11 @@ class Update extends TranslationBase '--password' => $input->getOption('password'), '--plugin' => $plugin ); + + if ($lastModDate != 0) { + $arguments['--lastupdate'] = $lastModDate; + } + $inputObject = new ArrayInput($arguments); $inputObject->setInteractive($input->isInteractive()); $command->run($inputObject, $output); |