Navigation Menu

Skip to content

Commit

Permalink
BO: Adding translation domains for Product Page - part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Even committed Jun 23, 2016
1 parent 00b5dc2 commit 76cfbc0
Show file tree
Hide file tree
Showing 20 changed files with 205 additions and 205 deletions.
26 changes: 13 additions & 13 deletions src/PrestaShopBundle/Controller/Admin/ProductController.php
Expand Up @@ -138,7 +138,7 @@ public function catalogAction(Request $request, $limit = 10, $offset = 0, $order
$toolbarButtons = array();
$toolbarButtons['add'] = array(
'href' => $this->generateUrl('admin_product_new'),
'desc' => $translator->trans('Add', array(), 'AdminProducts'),
'desc' => $translator->trans('Add', array(), 'Admin.Actions'),
'icon' => 'add'
);

Expand Down Expand Up @@ -170,7 +170,7 @@ public function catalogAction(Request $request, $limit = 10, $offset = 0, $order
'PrestaShopBundle\Form\Admin\Type\ChoiceCategoriesTreeType',
null,
array(
'label' => $translator->trans('Categories', array(), 'AdminProducts'),
'label' => $translator->trans('Categories', array(), 'Admin.Catalog.Feature'),
'list' => $this->container->get('prestashop.adapter.data_provider.category')->getNestedCategories(),
'valid_list' => [],
'multiple' => false,
Expand Down Expand Up @@ -311,7 +311,7 @@ public function newAction()
$toolsAdapter = $this->container->get('prestashop.adapter.tools');
$productAdapter = $this->container->get('prestashop.adapter.data_provider.product');
$translator = $this->container->get('translator');
$name = $translator->trans('New product', [], 'AdminProducts');
$name = $translator->trans('New product', [], 'Admin.Catalog.Feature');

$product = $productAdapter->getProductInstance();
$product->active = $productProvider->isNewProductDefaultActivated()? 1 : 0;
Expand Down Expand Up @@ -523,31 +523,31 @@ public function bulkAction(Request $request, $action)
$hookDispatcher->dispatchMultiple(['actionAdminActivateBefore', 'actionAdminProductsControllerActivateBefore'], $hookEventParameters);
// Hooks: managed in ProductUpdater
$productUpdater->activateProductIdList($productIdList);
$this->addFlash('success', $translator->trans('Product(s) successfully activated.', [], 'AdminProducts'));
$this->addFlash('success', $translator->trans('Product(s) successfully activated.', [], 'Admin.Catalog.Notification'));
$logger->info('Products activated: ('.implode(',', $productIdList).').');
$hookDispatcher->dispatchMultiple(['actionAdminActivateAfter', 'actionAdminProductsControllerActivateAfter'], $hookEventParameters);
break;
case 'deactivate_all':
$hookDispatcher->dispatchMultiple(['actionAdminDeactivateBefore', 'actionAdminProductsControllerDeactivateBefore'], $hookEventParameters);
// Hooks: managed in ProductUpdater
$productUpdater->activateProductIdList($productIdList, false);
$this->addFlash('success', $translator->trans('Product(s) successfully deactivated.', [], 'AdminProducts'));
$this->addFlash('success', $translator->trans('Product(s) successfully deactivated.', [], 'Admin.Catalog.Notification'));
$logger->info('Products deactivated: ('.implode(',', $productIdList).').');
$hookDispatcher->dispatchMultiple(['actionAdminDeactivateAfter', 'actionAdminProductsControllerDeactivateAfter'], $hookEventParameters);
break;
case 'delete_all':
$hookDispatcher->dispatchMultiple(['actionAdminDeleteBefore', 'actionAdminProductsControllerDeleteBefore'], $hookEventParameters);
// Hooks: managed in ProductUpdater
$productUpdater->deleteProductIdList($productIdList);
$this->addFlash('success', $translator->trans('Product(s) successfully deleted.', [], 'AdminProducts'));
$this->addFlash('success', $translator->trans('Product(s) successfully deleted.', [], 'Admin.Catalog.Notification'));
$logger->info('Products deleted: ('.implode(',', $productIdList).').');
$hookDispatcher->dispatchMultiple(['actionAdminDeleteAfter', 'actionAdminProductsControllerDeleteAfter'], $hookEventParameters);
break;
case 'duplicate_all':
$hookDispatcher->dispatchMultiple(['actionAdminDuplicateBefore', 'actionAdminProductsControllerDuplicateBefore'], $hookEventParameters);
// Hooks: managed in ProductUpdater
$productUpdater->duplicateProductIdList($productIdList);
$this->addFlash('success', $translator->trans('Product(s) successfully duplicated.', [], 'AdminProducts'));
$this->addFlash('success', $translator->trans('Product(s) successfully duplicated.', [], 'Admin.Catalog.Notification'));
$logger->info('Products duplicated: ('.implode(',', $productIdList).').');
$hookDispatcher->dispatchMultiple(['actionAdminDuplicateAfter', 'actionAdminProductsControllerDuplicateAfter'], $hookEventParameters);
break;
Expand Down Expand Up @@ -604,7 +604,7 @@ public function massEditAction(Request $request, $action)
);
// Hooks: managed in ProductUpdater
$productUpdater->sortProductIdList(array_combine($productIdList, $productPositionList), $productProvider->getPersistedFilterParameters());
$this->addFlash('success', $translator->trans('Products successfully sorted.', [], 'AdminProducts'));
$this->addFlash('success', $translator->trans('Products successfully sorted.', [], 'Admin.Catalog.Notification'));
$logger->info('Products sorted: ('.implode(',', $productIdList).') with positions ('.implode(',', $productPositionList).').');
$hookDispatcher->dispatchMultiple(
['actionAdminSortAfter', 'actionAdminProductsControllerSortAfter'],
Expand Down Expand Up @@ -661,15 +661,15 @@ public function unitAction(Request $request, $action, $id)
$hookDispatcher->dispatchMultiple(['actionAdminDeleteBefore', 'actionAdminProductsControllerDeleteBefore'], $hookEventParameters);
// Hooks: managed in ProductUpdater
$productUpdater->deleteProduct($id);
$this->addFlash('success', $translator->trans('Product successfully deleted.', [], 'AdminProducts'));
$this->addFlash('success', $translator->trans('Product successfully deleted.', [], 'Admin.Catalog.Notification'));
$logger->info('Product deleted: (' . $id . ').');
$hookDispatcher->dispatchMultiple(['actionAdminDeleteAfter', 'actionAdminProductsControllerDeleteAfter'], $hookEventParameters);
break;
case 'duplicate':
$hookDispatcher->dispatchMultiple(['actionAdminDuplicateBefore', 'actionAdminProductsControllerDuplicateBefore'], $hookEventParameters);
// Hooks: managed in ProductUpdater
$duplicateProductId = $productUpdater->duplicateProduct($id);
$this->addFlash('success', $translator->trans('Product successfully duplicated.', [], 'AdminProducts'));
$this->addFlash('success', $translator->trans('Product successfully duplicated.', [], 'Admin.Catalog.Notification'));
$logger->info('Product duplicated: (from ' . $id . ' to ' . $duplicateProductId . ').');
$hookDispatcher->dispatchMultiple(['actionAdminDuplicateAfter', 'actionAdminProductsControllerDuplicateAfter'], $hookEventParameters);
// stops here and redirect to the new product's page.
Expand All @@ -678,15 +678,15 @@ public function unitAction(Request $request, $action, $id)
$hookDispatcher->dispatchMultiple(['actionAdminActivateBefore', 'actionAdminProductsControllerActivateBefore'], $hookEventParameters);
// Hooks: managed in ProductUpdater
$productUpdater->activateProductIdList([$id]);
$this->addFlash('success', $translator->trans('Product successfully activated.', [], 'AdminProducts'));
$this->addFlash('success', $translator->trans('Product successfully activated.', [], 'Admin.Catalog.Notification'));
$logger->info('Product activated: '.$id);
$hookDispatcher->dispatchMultiple(['actionAdminActivateAfter', 'actionAdminProductsControllerActivateAfter'], $hookEventParameters);
break;
case 'deactivate':
$hookDispatcher->dispatchMultiple(['actionAdminDeactivateBefore', 'actionAdminProductsControllerDeactivateBefore'], $hookEventParameters);
// Hooks: managed in ProductUpdater
$productUpdater->activateProductIdList([$id], false);
$this->addFlash('success', $translator->trans('Product successfully deactivated.', [], 'AdminProducts'));
$this->addFlash('success', $translator->trans('Product successfully deactivated.', [], 'Admin.Catalog.Notification'));
$logger->info('Product deactivated: '.$id);
$hookDispatcher->dispatchMultiple(['actionAdminDeactivateAfter', 'actionAdminProductsControllerDeactivateAfter'], $hookEventParameters);
break;
Expand Down Expand Up @@ -839,7 +839,7 @@ public function renderFieldAction($productId, $step, $fieldName)

$form = $this->createFormBuilder($modelMapper->getFormData());

switch($step) {
switch ($step) {
case 'step1':
$form->add('step1', 'PrestaShopBundle\Form\Admin\Product\ProductInformation');
break;
Expand Down
Expand Up @@ -60,7 +60,7 @@ public function uploadImageAction($idProduct, Request $request)
->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType', array(
'error_bubbling' => true,
'constraints' => [
new Assert\NotNull(array('message' => $translator->trans('Please select a file', [], 'AdminProducts'))),
new Assert\NotNull(array('message' => $translator->trans('Please select a file', [], 'Admin.Catalog.Feature'))),
new Assert\Image(array('maxSize' => $this->configuration->get('PS_ATTACHMENT_MAXIMUM_SIZE').'M')),
]
))
Expand Down Expand Up @@ -132,11 +132,11 @@ public function formAction($idImage, Request $request)
'options' => [],
'locales' => $locales,
'hideTabs' => true,
'label' => $translator->trans('Legend', [], 'AdminProducts'),
'label' => $translator->trans('Legend', [], 'Admin.Catalog.Feature'),
'required' => false,
))
->add('cover', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', array(
'label' => $translator->trans('Choose as cover image', [], 'AdminProducts'),
'label' => $translator->trans('Choose as cover image', [], 'Admin.Catalog.Feature'),
'required' => false,
))
->getForm();
Expand Down
Expand Up @@ -76,7 +76,7 @@ protected function formatValidList($list)
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', array(
'label' => $this->translator->trans('Name', [], 'AdminGlobal'),
'label' => $this->translator->trans('Name', [], 'Admin.Global'),
'required' => false,
'attr' => ['placeholder' => $this->translator->trans('Category name', [], 'Admin.Catalog.Feature'), 'class' => 'ajax'],
'constraints' => $options['ajax'] ? [] : array(
Expand Down
10 changes: 5 additions & 5 deletions src/PrestaShopBundle/Form/Admin/Feature/ProductFeature.php
Expand Up @@ -69,7 +69,7 @@ public function __construct($translator, $legacyContext, $router, $featureDataPr
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('feature', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
'label' => $this->translator->trans('Feature', [], 'AdminProducts'),
'label' => $this->translator->trans('Feature', [], 'Admin.Catalog.Feature'),
'choices' => $this->features,
'choices_as_values' => true,
'required' => false,
Expand All @@ -80,7 +80,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
)
))
->add('value', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
'label' => $this->translator->trans('Pre-defined value', [], 'AdminProducts'),
'label' => $this->translator->trans('Pre-defined value', [], 'Admin.Catalog.Feature'),
'required' => false,
'choices_as_values' => true,
'attr' => array('class' => 'feature-value-selector')
Expand All @@ -91,7 +91,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'locales' => $this->locales,
'hideTabs' => true,
'required' => false,
'label' => $this->translator->trans('OR Customized value', [], 'AdminProducts'),
'label' => $this->translator->trans('OR Customized value', [], 'Admin.Catalog.Feature'),
));

$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
Expand All @@ -109,7 +109,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
);

$form->add('value', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
'label' => $this->translator->trans('Pre-defined value', [], 'AdminProducts'),
'label' => $this->translator->trans('Pre-defined value', [], 'Admin.Catalog.Feature'),
'choices' => $choices,
'choices_as_values' => true,
'required' => false,
Expand All @@ -133,7 +133,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
);

$form->add('value', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
'label' => $this->translator->trans('Pre-defined value', [], 'AdminProducts'),
'label' => $this->translator->trans('Pre-defined value', [], 'Admin.Catalog.Feature'),
'required' => false,
'attr' => array('class' => 'feature-value-selector'),
'choices' => $choices,
Expand Down
14 changes: 7 additions & 7 deletions src/PrestaShopBundle/Form/Admin/Product/ProductAttachement.php
Expand Up @@ -63,26 +63,26 @@ public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType', array(
'required' => false,
'label' => $this->translator->trans('File', [], 'AdminProducts'),
'label' => $this->translator->trans('File', [], 'Admin.Global'),
'constraints' => array(
new Assert\NotNull(array('message' => $this->translator->trans('Please select a file', [], 'AdminProducts'))),
new Assert\NotNull(array('message' => $this->translator->trans('Please select a file', [], 'Admin.Catalog.Feature'))),
new Assert\File(array('maxSize' => $this->configuration->get('PS_ATTACHMENT_MAXIMUM_SIZE').'M')),
)
))
->add('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', array(
'label' => $this->translator->trans('Filename', [], 'AdminProducts'),
'attr' => ['placeholder' => $this->translator->trans('Title', [], 'AdminProducts')],
'label' => $this->translator->trans('Filename', [], 'Admin.Global'),
'attr' => ['placeholder' => $this->translator->trans('Title', [], 'Admin.Global')],
'constraints' => array(
new Assert\NotBlank(),
new Assert\Length(array('min' => 2))
)
))
->add('description', 'Symfony\Component\Form\Extension\Core\Type\TextType', array(
'label' => $this->translator->trans('Description', [], 'AdminProducts'),
'attr' => ['placeholder' => $this->translator->trans('Description', [], 'AdminProducts')],
'label' => $this->translator->trans('Description', [], 'Admin.Global'),
'attr' => ['placeholder' => $this->translator->trans('Description', [], 'Admin.Global')],
))
->add('add', 'Symfony\Component\Form\Extension\Core\Type\ButtonType', array(
'label' => $this->translator->trans('Add', [], 'AdminProducts'),
'label' => $this->translator->trans('Add', [], 'Admin.Actions'),
'attr' => ['class' => 'btn-primary-outline pull-right']
));

Expand Down

0 comments on commit 76cfbc0

Please sign in to comment.