Jump to content

Condition in product description translation


Moncef Grey

Recommended Posts

i added new conditions to condition list and everythins works fine except the translation ( I wanna translate the new conditons from English to French )

Here's what i did:

in classes/Product.php i added the new conditions:

'condition' => array('type' => self::TYPE_STRING, 'shop' => true, 'validate' => 'isGenericName', 'values' => array('new', 'latest_available', 'pre_order', 'used', 'refurbished'), 'default' => 'new'),

 

in js/admin/products.js i did this:

tabs_manager.onLoad('Informations', function(){
	$('#condition').attr('disabled', true);
	$('#condition option[value=latest_available]').removeAttr('selected');
	$('#condition option[value=pre_order]').removeAttr('selected');
	$('#condition option[value=refurbished]').removeAttr('selected');
	$('#condition option[value=used]').removeAttr('selected');
});

 

in src/Adapter/Presenter/Product/ProductLazyArray.php i added these new cases:

case 'latest_available':
    return array(
        'type' => 'latest_available',
        'label' => $this->translator->trans('Latest available', array(), 'Shop.Theme.Catalog'),
        'schema_url' => 'https://schema.org/latest_availableCondition',
    );
    break;
case 'pre_order':
    return array(
        'type' => 'pre_order',
        'label' => $this->translator->trans('Pre-order', array(), 'Shop.Theme.Catalog'),
        'schema_url' => 'https://schema.org/pre_orderCondition',
    );
    break;

 

and finally in src/PrestaShopBundle/Form/Admin/Product/ProductOptions.php i added this:

->add('condition', FormType\ChoiceType::class, [
    'choices' => [
        $this->translator->trans('New', [], 'Shop.Theme.Catalog') => 'new',
        $this->translator->trans('Latest available', [], 'Shop.Theme.Catalog') => 'latest_available',
        $this->translator->trans('Pre-order', [], 'Shop.Theme.Catalog') => 'pre_order',
        $this->translator->trans('Used', [], 'Shop.Theme.Catalog') => 'used',
        $this->translator->trans('Refurbished', [], 'Shop.Theme.Catalog') => 'refurbished',
    ],
    'attr' => [
        'class' => 'custom-select',
    ],
    'required' => true,
    'label' => $this->translator->trans('Condition', [], 'Admin.Catalog.Feature'),
])

 

yet the translation isn't working even the whole website and the BO are in French !

Screenshot 2021-10-24 143806.png

Link to comment
Share on other sites

What Moncef Grey is trying to ask exactly is how to add a new string into the translation, a new custom string.

In this example, the string "latest available" is a custom value that isn't provided within the translated strings of prestashop themes

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...