Magento – How to translate “x has been added to your Wish List. Click here to continue shopping.”

magento2

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

Best Answer

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.

Related Topic