.po 文件中的 CakePhp i18n 翻译词顺序

CakePhp i18n translation words order in .po files

目前在一个视图中我有这个:

<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>

在我的 .po 文件中我有这个:

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

我得到的翻译(从法语 - msgid - 到英语 - msgstr -)是错误的。

msgstr 中的第一个 %s 值应该是 msgid 中的第三个 %s 值。 我为 cakephp 做了一些与 i18n 相关的研究,但我没有找到任何与我的问题相关的东西。

您知道如何 'set the order' 翻译的 %s 吗?

谢谢。

我过去在将替换参数作为多个函数参数传递时遇到过问题。使用数组往往更可靠:-

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

更新:

您需要在翻译后的字符串中指定正确的顺序,如下所示:-

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

使用 %3$s 告诉 Cake 使用哪个参数,整数代表原始顺序。