# How to correctly translate a message in Function \_\_d

**URL:** <https://discourse.cakephp.org/t/how-to-correctly-translate-a-message-in-function-d/11034>\
**Category:** Need Help\
**Tags:** translation, behavior, help\
**Created:** [March 9, 2023, 6:56pm UTC](https://discourse.cakephp.org/t/how-to-correctly-translate-a-message-in-function-d/11034 "2023-03-09T18:56:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![krimz\_oles33](https://avatars.discourse-cdn.com/v4/letter/k/67e7ee/32.png) [@krimz\_oles33](https://discourse.cakephp.org/u/krimz_oles33)\
**Post date:** [March 9, 2023, 6:56pm UTC](https://discourse.cakephp.org/t/how-to-correctly-translate-a-message-in-function-d/11034/1 "2023-03-09T18:56:37Z")

</div>

Hi!,

```auto
echo $this - > Html - > para(
        'small white-600 js-box',
        $this - > getDiscount() - > isValid() ?
        __d(
            'Discount.discount',
            'Discount.validLink', [
                'confirm' => $confirm,
                'link' => $pagesInstance - > getPage(WWWPages::validLink)['url'],
            ]
        ) :
        __d(
            'Discount.discount',
            'Discount.invalidLink', [
                'confirm' => $confirm,
                'link' => $pagesInstance - > getPage(WWWPages::invalidLink)['url'],
            ]
        )
)

```

Here I have such a piece of code that displays a translated message depending on whether the discount is valid or not. And so far it has worked correctly.

But I would like to extend this with another message, namely, if the rebate was not valid, then additionally there would be a check if this rebate has an “entitlement”. If it had it would display the current message (`Discount.invalidLink`), and if not have it would display a modified message. (all checking is already done on the JS side) now I need to put this message somehow in cakePHP.

The message has to be based on the current one i.e. `Discount.invalidLink` and its content would simply be modified. The first line in both would be the same, only the second line would be different.

Here is what such a message looks like:

```auto
msgid "Discount.invalidLink"
msgstr "Check your transaction {confirm}. "
"<span> Your invalid link <a href=\"{link}\" target=\"_blank\"></a> </span>"" 

```

I put the second line of the message in `<span>` and depending on whether there was an “entitlement” discount, only the first part would be displayed and if not the whole message.

And here I am wondering how to execute it should I create another function` __d` and try to pass` .echo $this->Html->tag('span', text, ['class' => '.js inValid-link']` or is it enough to maybe pass this directly to the second function `__d`?

How could I do that?

Thanks in advance for your help!
