Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add command fop:translations:import #262

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 36 additions & 33 deletions config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
44 changes: 44 additions & 0 deletions src/Commands/Translations/ImportLanguage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

Check failure on line 1 in src/Commands/Translations/ImportLanguage.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.5.2)

ParseError (syntax error, unexpected ')') thrown while looking for class FOP\Console\Commands\Translations\ImportLanguage.

Check failure on line 1 in src/Commands/Translations/ImportLanguage.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.6.9)

ParseError (syntax error, unexpected ')') thrown while looking for class FOP\Console\Commands\Translations\ImportLanguage.

Check failure on line 1 in src/Commands/Translations/ImportLanguage.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.7.8)

ParseError (syntax error, unexpected ')') thrown while looking for class FOP\Console\Commands\Translations\ImportLanguage.

Check failure on line 1 in src/Commands/Translations/ImportLanguage.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.8.5)

ParseError (syntax error, unexpected ')') thrown while looking for class FOP\Console\Commands\Translations\ImportLanguage.

namespace FOP\Console\Commands\Translations;

use FOP\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

final class ImportLanguage extends Command
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('fop:translations')
PrestaSafe marked this conversation as resolved.
Show resolved Hide resolved
->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 )')
PrestaSafe marked this conversation as resolved.
Show resolved Hide resolved
->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 !');
}
Copy link

@StoreCommanderDev StoreCommanderDev Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If 1 is for failure.

Does the code must be

if (!empty($errors)) {
    return Command::FAILURE_EXIT;
}
$this->io->text('lang '.$iso.' added !');
return Command::SUCCESS:

instead?


return 0; // return 0 on success or 1 on failure.
PrestaSafe marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading