diff options
author | sgiehl <stefan@piwik.org> | 2015-05-13 22:51:48 +0300 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2015-05-13 22:51:48 +0300 |
commit | 699f232efff1b67026dc1e55306f1ff90f7986ce (patch) | |
tree | 201b00391a72894c6b09f3b7414eae496d7626d5 /plugins/LanguagesManager | |
parent | 7eb55f2cc512bc3dbc893ea8d39f21f367e2759a (diff) |
refs #7883 - make it possible to update translations without beeing a maintainer on transifex
Diffstat (limited to 'plugins/LanguagesManager')
-rw-r--r-- | plugins/LanguagesManager/API.php | 2 | ||||
-rw-r--r-- | plugins/LanguagesManager/Commands/FetchTranslations.php | 25 |
2 files changed, 18 insertions, 9 deletions
diff --git a/plugins/LanguagesManager/API.php b/plugins/LanguagesManager/API.php index ca491892ed..82209a495e 100644 --- a/plugins/LanguagesManager/API.php +++ b/plugins/LanguagesManager/API.php @@ -50,7 +50,7 @@ class API extends \Piwik\Plugin\API /** * Return array of available languages * - * @return array Arry of strings, each containing its ISO language code + * @return array Array of strings, each containing its ISO language code */ public function getAvailableLanguages() { diff --git a/plugins/LanguagesManager/Commands/FetchTranslations.php b/plugins/LanguagesManager/Commands/FetchTranslations.php index 532d1061d8..79f83da36d 100644 --- a/plugins/LanguagesManager/Commands/FetchTranslations.php +++ b/plugins/LanguagesManager/Commands/FetchTranslations.php @@ -10,6 +10,7 @@ namespace Piwik\Plugins\LanguagesManager\Commands; use Piwik\Container\StaticContainer; +use Piwik\Exception\AuthenticationFailedException; use Piwik\Plugins\LanguagesManager\API as LanguagesManagerApi; use Piwik\Translation\Transifex\API; use Symfony\Component\Console\Helper\ProgressHelper; @@ -57,14 +58,6 @@ class FetchTranslations extends TranslationBase $output->writeln("Fetching translations from Transifex for resource $resource"); - $languages = $transifexApi->getAvailableLanguageCodes(); - - if (!empty($plugin)) { - $languages = array_filter($languages, function($language) { - return LanguagesManagerApi::getInstance()->isLanguageAvailable(str_replace('_', '-', strtolower($language))); - }); - } - $availableLanguages = LanguagesManagerApi::getInstance()->getAvailableLanguageNames(); $languageCodes = array(); @@ -72,6 +65,22 @@ class FetchTranslations extends TranslationBase $languageCodes[] = $languageInfo['code']; } + $languageCodes = array_filter($languageCodes, function($code) { + return !in_array($code, array('en', 'dev')); + }); + + try { + $languages = $transifexApi->getAvailableLanguageCodes(); + + if (!empty($plugin)) { + $languages = array_filter($languages, function ($language) { + return LanguagesManagerApi::getInstance()->isLanguageAvailable(str_replace('_', '-', strtolower($language))); + }); + } + } catch (AuthenticationFailedException $e) { + $languages = $languageCodes; + } + /** @var ProgressHelper $progress */ $progress = $this->getHelperSet()->get('progress'); |