3
votes

Currently in a view I have this:

<span style="color: #2363a2;"><?php echo __('Accèdez à tous les %spronostics%s d\'%s', '<span style="font-weight: bold; text-transform: uppercase">', '</span>', AppController::getSiteName()); ?></span>

In my .po file I have this:

msgid "Accèdez à tous les %spronostics%s d'%s"
msgstr "Reach all the %s %spicks%s"

The translation I get (from french - msgid - to english - msgstr -) is wrong.

The 1st %s value in msgstr should be the 3rd %s value in msgid. I did some researches related to i18n for cakephp but I didn't find nothing related to my issue.

Do you know how to 'set the order' of the translated %s ?

Thanks.

1

1 Answers

1
votes

I've had issues in the past when passing the replacement arguments as multiple function arguments. Using an array tends to be more reliable:-

__(
    'Accèdez à tous les %spronostics%s d\'%s', 
    [
        '<span style="font-weight: bold; text-transform: uppercase">', 
        '</span>', 
        AppController::getSiteName()
    ]
)

Update:

You need to specify the correct order in the translated string like this:-

msgid "Accèdez à tous les %spronostics%s d'%s"
msgstr "Reach all the %3$s %1$spicks%2$s"

Using %3$s tells Cake which of the parameters to use where the integer number represents the original ordering.