我们有一个.po
文件,该文件会转换为.mo
文件,以便与Symfony 4 Translations library一起使用。使用transChoice
方法时,我们遇到了问题。
以下是原始.po
文件中的内容。
msgid "%count% person has been updated successfully!"
msgid_plural "%count% people have been updated successfully!"
msgstr[0] "%count% person har blitt oppdatert!"
msgstr[1] "%count% personer har blitt oppdatert!"
我们已启用缓存,当加载缓存的PHP文件时,它会将上述内容转换为以下内容:
'%count% person has been updated successfully!' => '%count% person har blitt oppdatert!',
'%count% people have been updated successfully!' => '{0} %count% person har blitt oppdatert!|{1} %count% personer har blitt oppdatert!',
似乎复数具有单数和复数形式。这是正确的吗?在使用$id
方法时,我应该始终使用transChoice
的复数形式吗?
例如:做这个
$this->translator->transChoice(
'%count% people have been updated successfully!',
5,
array(
'%count%' => 5
)
);
...而不是这个
$this->translator->transChoice(
'%count% person has been updated successfully!|%count% people have been updated successfully!',
5,
array(
'%count%' => 5
)
);