php - 多个复数条件翻译
问题描述
我尝试使用翻译服务来翻译包含 2 个复数单词的句子,请参见下面的示例:
$countToBeDownloded = 2;
$allowedToDl = 0;
$countToBeDownloded1 = 15;
$allowedToDl1 = 4;
/*
* Sentence :
*
* `You tried to download {countToBeDownloded} image|images but your daily quota allow you to download only
* {allowedToDl} image|images`
*/
$this->translator->trans('mymessage', ['countToBeDownloded' => $countToBeDownloded, 'allowedToDl' => $allowedToDl]);
// mymessage output : You tried to download 2 images but your daily quota allow you to download only 0 image
$this->translator->trans('mymessage2', ['countToBeDownloded' => $countToBeDownloded1, 'allowedToDl' => $allowedToDl1]);
// mymessage output : You tried to download 15 images but your daily quota allow you to download only 4 images
如您所见,我必须使用and翻译image
两次。countToBeDownloded
allowedToDl
有我的 yaml 翻译文件
mymessage: |-
{countToBeDownloded, plural,
=1 {You tried to download # image but your daily quota allow you to download only {allowedToDl} images}
other {You tried to download # images but your daily quota allow you to download only {allowedToDl} images}
}
有办法实现吗?
解决方案
推荐阅读
- android - WorkManager onStopped() 方法被调用两次
- c++ - stringstream::seekp 在 Visual Studio 2015 上不起作用
- python - 更改 Django/Postgres db_table 名称
- java - @PostConstruct 不适用于特定类名的springboot
- python - 在两个cmd窗口中启动和重启python程序
- c# - 如何在 Cybersource Simple Order API 中使用部分退款
- java - FirebaseRecyclerAdapter 中的数据库查询
- c# - 如何在 Quartz.net 的作业类中使用我的一些服务和存储库?
- compiler-errors - 如何使用线程启用编译 libstdc++
- html - BeautifulSoup 将输出美化为 html