Symfony4 复数翻译不起作用

jmu*_*zco 0 icu symfony twig symfony4

当我对消息使用新的 ICU 格式时,多元化在 Symfony4.3 中部分工作。

预期行为: One item found

当前行为: {1, plural, =0 {No items found.} one {One item found.} other {# items found.} }

翻译文件适用于其他翻译,所以我认为配置是正确的。在translations/messagges.en.yaml

msg:
    photos:
        uploaded: >
            {photos, plural,
                =0 {No items found.}
                one {One item found.}
                other {# items found.}
            }
Run Code Online (Sandbox Code Playgroud)

在模板中有以下行:

{{ 'msg.photos.uploaded'|trans({'photos': 1}) }}
Run Code Online (Sandbox Code Playgroud)

Jak*_*umi 5

我相信,要使 ICU 消息格式正常工作,文件名必须正确(更准确地说,必须+intl-icu附加域):

https://symfony.com/doc/current/translation/message_format.html#using-the-icu-message-format

在你的情况下,文件名应该是:translations/messages+intl-icu.en.yaml根据上面的来源。