diff --git a/bin/cli b/bin/cli index abbeed47..66086b23 100755 --- a/bin/cli +++ b/bin/cli @@ -2,16 +2,10 @@ get('translator'); -$translator->setLocale(env('CLI_LOCALE', 'en')); - -/** @var Application $app */ +/** @var CliApp $app */ $app = $container->get(CliApp::class); $app->run(); diff --git a/config/autoload/app_options.global.php b/config/autoload/app_options.global.php index 4db642ce..e3f8fbdd 100644 --- a/config/autoload/app_options.global.php +++ b/config/autoload/app_options.global.php @@ -3,7 +3,7 @@ return [ 'app_options' => [ 'name' => 'Shlink', - 'version' => '1.1.0', + 'version' => '1.2.0', 'secret_key' => env('SECRET_KEY'), ], diff --git a/module/CLI/config/cli.config.php b/module/CLI/config/cli.config.php index 1244e259..31c4e460 100644 --- a/module/CLI/config/cli.config.php +++ b/module/CLI/config/cli.config.php @@ -4,6 +4,7 @@ use Shlinkio\Shlink\CLI\Command; return [ 'cli' => [ + 'locale' => env('CLI_LOCALE', 'en'), 'commands' => [ Command\Shortcode\GenerateShortcodeCommand::class, Command\Shortcode\ResolveUrlCommand::class, diff --git a/module/CLI/src/Factory/ApplicationFactory.php b/module/CLI/src/Factory/ApplicationFactory.php index a8e24bf3..d13cce7c 100644 --- a/module/CLI/src/Factory/ApplicationFactory.php +++ b/module/CLI/src/Factory/ApplicationFactory.php @@ -3,7 +3,9 @@ namespace Shlinkio\Shlink\CLI\Factory; use Interop\Container\ContainerInterface; use Interop\Container\Exception\ContainerException; +use Shlinkio\Shlink\Core\Options\AppOptions; use Symfony\Component\Console\Application as CliApp; +use Zend\I18n\Translator\Translator; use Zend\ServiceManager\Exception\ServiceNotCreatedException; use Zend\ServiceManager\Exception\ServiceNotFoundException; use Zend\ServiceManager\Factory\FactoryInterface; @@ -25,9 +27,12 @@ class ApplicationFactory implements FactoryInterface public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $config = $container->get('config')['cli']; - $app = new CliApp('Shlink', '1.0.0'); + $appOptions = $container->get(AppOptions::class); + $translator = $container->get(Translator::class); + $translator->setLocale($config['locale']); $commands = isset($config['commands']) ? $config['commands'] : []; + $app = new CliApp($appOptions->getName(), $appOptions->getVersion()); foreach ($commands as $command) { if (! $container->has($command)) { continue;