From 4dbbed3b66adaa905a242f2182ba721801c6c2d6 Mon Sep 17 00:00:00 2001 From: Prestasafe Date: Mon, 8 Apr 2024 16:24:06 +0200 Subject: [PATCH 1/4] add new command php bin/console fop:translations:import ISO_CODE --- config/services.yml | 69 ++++++++++---------- src/Commands/Translations/ImportLanguage.php | 44 +++++++++++++ 2 files changed, 80 insertions(+), 33 deletions(-) create mode 100644 src/Commands/Translations/ImportLanguage.php diff --git a/config/services.yml b/config/services.yml index 403e9fc1..bb94de8f 100644 --- a/config/services.yml +++ b/config/services.yml @@ -11,136 +11,139 @@ services: fop.console.cache.clear.command: class: FOP\Console\Commands\Cache\CacheClear - tags: [ console.command ] + tags: [console.command] fop.console.category.clean.command: class: FOP\Console\Commands\Category\CategoryClean - tags: [ console.command ] + tags: [console.command] fop.console.category.products_count.command: class: FOP\Console\Commands\Category\CategoryProductsCount - tags: [ console.command ] + tags: [console.command] fop.console.configuration.export.command: class: FOP\Console\Commands\Configuration\ConfigurationExport - tags: [ console.command ] + tags: [console.command] fop.console.configuration.import.command: class: FOP\Console\Commands\Configuration\ConfigurationImport - tags: [ console.command ] + tags: [console.command] fop.console.container.check.command: class: FOP\Console\Commands\Container\ContainerCheck - tags: [ console.command ] + tags: [console.command] fop.console.employee.list.command: class: FOP\Console\Commands\Employee\EmployeeList - tags: [ console.command ] + tags: [console.command] fop.console.employee.change_password.command: class: FOP\Console\Commands\Employee\EmployeeChangePassword - tags: [ console.command ] + tags: [console.command] fop.console.environment.debug.command: class: FOP\Console\Commands\Environment\EnvironmentDebug - tags: [ console.command ] + tags: [console.command] fop.console.environment.get_parameters.command: class: FOP\Console\Commands\Environment\EnvironmentGetParameters - tags: [ console.command ] + tags: [console.command] fop.console.environment.setup_dev.command: class: FOP\Console\Commands\Environment\EnvironmentSetupDev - tags: [ console.command ] + tags: [console.command] fop.console.export.data.command: class: FOP\Console\Commands\Export\ExportData - tags: [ console.command ] + tags: [console.command] fop.console.generate.htaccess.command: class: FOP\Console\Commands\Generate\GenerateHtaccess - tags: [ console.command ] + tags: [console.command] fop.console.generate.robots.command: class: FOP\Console\Commands\Generate\GenerateRobots - tags: [ console.command ] + tags: [console.command] fop.console.group.transfer_customers.command: class: FOP\Console\Commands\Group\GroupTransferCustomers - tags: [ console.command ] + tags: [console.command] fop.console.hook.add.command: class: FOP\Console\Commands\Hook\HookAdd - tags: [ console.command ] + tags: [console.command] fop.console.image.generate_products.command: class: FOP\Console\Commands\Image\ImageGenerateProducts - tags: [ console.command ] + tags: [console.command] fop.console.image.generate_categories.command: class: FOP\Console\Commands\Image\ImageGenerateCategories - tags: [ console.command ] + tags: [console.command] fop.console.image.generate_manufacturers.command: class: FOP\Console\Commands\Image\ImageGenerateManufacturers - tags: [ console.command ] + tags: [console.command] fop.console.image.generate_suppliers.command: class: FOP\Console\Commands\Image\ImageGenerateSuppliers - tags: [ console.command ] + tags: [console.command] fop.console.image.generate_stores.command: class: FOP\Console\Commands\Image\ImageGenerateStores - tags: [ console.command ] + tags: [console.command] fop.console.module.unhook.command: class: FOP\Console\Commands\Module\ModuleUnhook - tags: [ console.command ] + tags: [console.command] fop.console.module.hook.command: class: FOP\Console\Commands\Module\ModuleHook - tags: [ console.command ] + tags: [console.command] fop.console.module.hooks.command: class: FOP\Console\Commands\Module\ModuleHooks - tags: [ console.command ] + tags: [console.command] fop.console.module.rename.command: class: FOP\Console\Commands\Module\ModuleRename - tags: [ console.command ] + tags: [console.command] fop.console.module.non_essential.command: class: FOP\Console\Commands\Module\ModuleNonEssential - tags: [ console.command ] + tags: [console.command] fop.console.module.generate.command: class: FOP\Console\Commands\Module\ModuleGenerate - tags: [ console.command ] + tags: [console.command] fop.console.override.make.command: class: FOP\Console\Commands\Override\OverrideMake - tags: [ console.command ] + tags: [console.command] fop.console.product.latest.command: class: FOP\Console\Commands\Product\ProductLatest - tags: [ console.command ] + tags: [console.command] fop.console.shop.status.command: class: FOP\Console\Commands\Shop\ShopStatus - tags: [ console.command ] + tags: [console.command] fop.console.shop.maintenance.command: class: FOP\Console\Commands\Shop\ShopMaintenance - tags: [ console.command ] + tags: [console.command] fop.console.theme.reset_layout.command: class: FOP\Console\Commands\Theme\ThemeResetLayout - tags: [ console.command ] + tags: [console.command] fop.console.about.version.command: class: FOP\Console\Commands\About\AboutVersion - tags: [ console.command ] + tags: [console.command] + fop.console.translations.command: + class: FOP\Console\Commands\Translations\ImportLanguage + tags: [console.command] imports: - { resource: overriders.yml } diff --git a/src/Commands/Translations/ImportLanguage.php b/src/Commands/Translations/ImportLanguage.php new file mode 100644 index 00000000..44244a62 --- /dev/null +++ b/src/Commands/Translations/ImportLanguage.php @@ -0,0 +1,44 @@ +setName('fop:translations') + ->setName('fop:translations:import') + ->setDescription('Import a translation by iso code') + ->setHelp('This command will import or update a translation package') + ->addUsage('./bin/console op:translations:import fr ( import fr translation package )') + ->addArgument( + 'iso', + InputOption::VALUE_REQUIRED, + 'iso of language to import ex: fr', + ); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $iso = $input->getArgument('iso'); + $languagePackImporter = $this->getContainer()->get('prestashop.adapter.language.pack.importer'); + $errors = $languagePackImporter->import($iso); + if (empty($errors)) { + $this->io->text('lang '.$iso.' added !'); + } + + return 0; // return 0 on success or 1 on failure. + } +} \ No newline at end of file From 2f2f76c51fb9b576db973ee30176b66491ecd8d7 Mon Sep 17 00:00:00 2001 From: Guillaume Batier Date: Tue, 9 Apr 2024 13:49:40 +0200 Subject: [PATCH 2/4] Update src/Commands/Translations/ImportLanguage.php Co-authored-by: Jonathan Danse --- src/Commands/Translations/ImportLanguage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/Translations/ImportLanguage.php b/src/Commands/Translations/ImportLanguage.php index 44244a62..0134d246 100644 --- a/src/Commands/Translations/ImportLanguage.php +++ b/src/Commands/Translations/ImportLanguage.php @@ -39,6 +39,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->io->text('lang '.$iso.' added !'); } - return 0; // return 0 on success or 1 on failure. + return Command::SUCCESS; } } \ No newline at end of file From 4e143dfe0ded10b0b9ba79ebb58c88a8f7b30f81 Mon Sep 17 00:00:00 2001 From: Guillaume Batier Date: Tue, 9 Apr 2024 13:49:54 +0200 Subject: [PATCH 3/4] Update src/Commands/Translations/ImportLanguage.php Co-authored-by: Touxten <156076965+Touxten@users.noreply.github.com> --- src/Commands/Translations/ImportLanguage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/Translations/ImportLanguage.php b/src/Commands/Translations/ImportLanguage.php index 0134d246..cd767d86 100644 --- a/src/Commands/Translations/ImportLanguage.php +++ b/src/Commands/Translations/ImportLanguage.php @@ -19,7 +19,7 @@ protected function configure() ->setName('fop:translations:import') ->setDescription('Import a translation by iso code') ->setHelp('This command will import or update a translation package') - ->addUsage('./bin/console op:translations:import fr ( import fr translation package )') + ->addUsage('./bin/console fop:translations:import fr import fr translation package ') ->addArgument( 'iso', InputOption::VALUE_REQUIRED, From 3caab0585c1d4877ec5044b4e5d4ef232615cd88 Mon Sep 17 00:00:00 2001 From: Guillaume Batier Date: Tue, 9 Apr 2024 13:59:18 +0200 Subject: [PATCH 4/4] Update src/Commands/Translations/ImportLanguage.php Co-authored-by: Jonathan Danse --- src/Commands/Translations/ImportLanguage.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Commands/Translations/ImportLanguage.php b/src/Commands/Translations/ImportLanguage.php index cd767d86..e40d03a9 100644 --- a/src/Commands/Translations/ImportLanguage.php +++ b/src/Commands/Translations/ImportLanguage.php @@ -15,7 +15,6 @@ final class ImportLanguage extends Command protected function configure() { $this - ->setName('fop:translations') ->setName('fop:translations:import') ->setDescription('Import a translation by iso code') ->setHelp('This command will import or update a translation package')