Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2019-01-21 18:44:35 +0300
committerGitHub <noreply@github.com>2019-01-21 18:44:35 +0300
commit7395c84d061505e5f05abf60cb6773d00cc650bf (patch)
tree29bba493753f017fca04a498f807b265f688a798
parent892e6f175965b5d56df2f5546e1adf5a417f325a (diff)
Improve/Fix translation commands (#13982)
-rw-r--r--plugins/Intl/Commands/GenerateIntl.php10
-rw-r--r--plugins/LanguagesManager/Commands/SetTranslations.php2
-rw-r--r--plugins/LanguagesManager/Commands/Update.php19
-rw-r--r--plugins/LanguagesManager/TranslationWriter/Validate/CoreTranslations.php4
4 files changed, 30 insertions, 5 deletions
diff --git a/plugins/Intl/Commands/GenerateIntl.php b/plugins/Intl/Commands/GenerateIntl.php
index b7d199c290..1b781b5503 100644
--- a/plugins/Intl/Commands/GenerateIntl.php
+++ b/plugins/Intl/Commands/GenerateIntl.php
@@ -17,6 +17,7 @@ use Piwik\Filesystem;
use Piwik\Http;
use Piwik\Plugin\ConsoleCommand;
use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
@@ -34,6 +35,7 @@ class GenerateIntl extends ConsoleCommand
protected function configure()
{
$this->setName('translations:generate-intl-data')
+ ->addOption('language', 'l', InputOption::VALUE_OPTIONAL, 'language that should be fetched')
->setDescription('Generates Intl-data for Piwik');
}
@@ -58,7 +60,11 @@ class GenerateIntl extends ConsoleCommand
protected function execute(InputInterface $input, OutputInterface $output)
{
- $piwikLanguages = \Piwik\Plugins\LanguagesManager\API::getInstance()->getAvailableLanguages();
+ $matomoLanguages = \Piwik\Plugins\LanguagesManager\API::getInstance()->getAvailableLanguages();
+
+ if ($input->getOption('language')) {
+ $matomoLanguages = [$input->getOption('language')];
+ }
$aliasesUrl = 'https://raw.githubusercontent.com/unicode-cldr/cldr-core/master/supplemental/aliases.json';
$aliasesData = Http::fetchRemoteFile($aliasesUrl);
@@ -69,7 +75,7 @@ class GenerateIntl extends ConsoleCommand
$writePath = Filesystem::getPathToPiwikRoot() . '/plugins/Intl/lang/%s.json';
- foreach ($piwikLanguages AS $langCode) {
+ foreach ($matomoLanguages AS $langCode) {
if ($langCode == 'dev') {
continue;
diff --git a/plugins/LanguagesManager/Commands/SetTranslations.php b/plugins/LanguagesManager/Commands/SetTranslations.php
index 540471ce59..beec434a31 100644
--- a/plugins/LanguagesManager/Commands/SetTranslations.php
+++ b/plugins/LanguagesManager/Commands/SetTranslations.php
@@ -42,7 +42,7 @@ class SetTranslations extends TranslationBase
$languageCode = $input->getOption('code');
$filename = $input->getOption('file');
- $languageCodes = API::getInstance()->getAvailableLanguages();
+ $languageCodes = (new API())->getAvailableLanguages();
if (empty($languageCode) || !in_array($languageCode, $languageCodes)) {
$languageCode = $dialog->askAndValidate($output, 'Please provide a valid language code: ', function ($code) use ($languageCodes) {
diff --git a/plugins/LanguagesManager/Commands/Update.php b/plugins/LanguagesManager/Commands/Update.php
index a4a664b455..cfe0472b31 100644
--- a/plugins/LanguagesManager/Commands/Update.php
+++ b/plugins/LanguagesManager/Commands/Update.php
@@ -9,6 +9,7 @@
namespace Piwik\Plugins\LanguagesManager\Commands;
+use Piwik\Cache;
use Piwik\Plugin\Manager;
use Piwik\Plugins\LanguagesManager\API;
use Symfony\Component\Console\Helper\DialogHelper;
@@ -109,7 +110,21 @@ class Update extends TranslationBase
}
@touch(PIWIK_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . $code . '.json');
- API::unsetInstance(); // unset language manager instance, so valid names are refetched
+ API::unsetAllInstances(); // unset language manager instance, so valid names are refetched
+
+ $command = $this->getApplication()->find('translations:generate-intl-data');
+ $arguments = array(
+ 'command' => 'translations:generate-intl-data',
+ '--language' => $code,
+ );
+ $inputObject = new ArrayInput($arguments);
+ $inputObject->setInteractive($input->isInteractive());
+ $command->run($inputObject, $output->isVeryVerbose() ? $output : new NullOutput());
+
+ API::unsetAllInstances(); // unset language manager instance, so valid names are refetched
+ Cache::flushAll();
+
+ $languageCodes[] = $code;
}
$command = $this->getApplication()->find('translations:set');
@@ -121,7 +136,7 @@ class Update extends TranslationBase
);
$inputObject = new ArrayInput($arguments);
$inputObject->setInteractive($input->isInteractive());
- $command->run($inputObject, new NullOutput());
+ $command->run($inputObject, $output->isVeryVerbose() ? $output : new NullOutput());
}
$progress->finish();
diff --git a/plugins/LanguagesManager/TranslationWriter/Validate/CoreTranslations.php b/plugins/LanguagesManager/TranslationWriter/Validate/CoreTranslations.php
index bcdfc66974..c089c30eb0 100644
--- a/plugins/LanguagesManager/TranslationWriter/Validate/CoreTranslations.php
+++ b/plugins/LanguagesManager/TranslationWriter/Validate/CoreTranslations.php
@@ -68,6 +68,10 @@ class CoreTranslations extends ValidateAbstract
$allLanguages = $languageDataProvider->getLanguageList();
$allCountries = $regionDataProvider->getCountryList();
+ if ('eo.UTF-8' === $translations['General']['Locale']) {
+ return true;
+ }
+
if (!preg_match('/^([a-z]{2})_([A-Z]{2})\.UTF-8$/', $translations['General']['Locale'], $matches)) {
$this->message = self::ERRORSTATE_LOCALEINVALID;
return false;