0

The string "x has been added to your Wish List. Click here to continue shopping." can be found in the template Magento/Wishlist/view/frontend/templates/messages/addProductSuccessMessage.phtml

But it doesn't the usual pattern

<?php /* @escapeNotVerified */ echo __('Some string you can translate') ?>

What should I write in my csv file?

Below the template file

<?php
echo $block
    ->escapeHtml(
        $block->getData('product_name')
    )
?> has been added to your Wish List. Click <a href="<?php
echo $block
    ->escapeUrl(
        $block->getData('referer')
    )
?>">here</a> to continue shopping.

edit 02.09.2019

Since the question was asked, the template file has been updated to be translatable https://github.com/magento/magento2/commit/624173e59cdbb5f4203ce346b1b53637f32672ef#diff-7586a821ac9c752c277b0c4304885b76

0

Usually you would use sprintf to pass in the dynamic details then you can use the formatting string to do translation.

Example:

$message = sprintf("%s has been added to your cart.", $product->getName());

Then in your csv you would just include: %s has been added to your cart. And then translate to whatever language you require, keeping the %s.

  • Thanks for your answer. I read in an article that Magento 2 translations were not sprintf compatible. But I'll take your suggestion and override the template file. magento-quickies.alanstorm.com/post/137168044820/… – csmarvz Jan 21 '16 at 9:07
  • @csmarvz if you satisfied with the answer, please mark it as accepted. – Tailtiu Aug 31 '19 at 10:25
0

According official documentation about translation in Magento 2 you should create a dictionnary CSV file in your theme folder.

app/design/frontend/Magento/demo/i18n/fr_FR.csv

"%1 has been added to your Wish List. Click here to continue shopping.","%1 a été ajouté à votre liste de favoris"

Any PHP file

$messageManager->addSuccessMessage(__('%1 has been added to your Wish List. Click here to continue shopping.', $product->getName()));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.