国际化含有两个复数单词的句子
使用 gettext 如何使具有多个数字变量的句子可翻译? ngettext 只接受一个数字作为复数参数。
以下句子中应允许的排列是“成人和儿童”、“成人和儿童”、“成人和儿童”和“成人和儿童”。
“#NUMADULTS 成人和 #NUMCHILDREN 儿童从 #AVAILABILITYFROM 到 #AVAILABILITYTO”
Using gettext how should a sentence with multiple numeric variables be made translatable? ngettext only takes one number as the plural parameter.
The permutations that should be allowed in the below sentence are "adult and child", "adults and child", "adult and children" and "adults and children".
"from #AVAILABILITYFROM to #AVAILABILITYTO for #NUMADULTS adult and #NUMCHILDREN child"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在英语以外的其他一些语言中,语法可能非常复杂,您应该意识到使用您的方法实际上不可能生成正确的复杂句子。
请记住,多个变量和类型(男性/女性)也会增加很多复杂性。
解决方案是仅生成只有一个变量的简单句子。
ngettext
支持这种情况。要知道 ngettext 是很棒的东西,而大多数 bug 软件公司的商业 i18n 框架甚至不支持它。即使如此,它也有其局限性,所以很快您的问题的解决方案就是将复杂的句子分成几个简单的句子,这些简单的句子只能使用一个变量进行翻译。
Grammar can be very complex in some other languages than English and you should be aware that is practical impossible to generate correct complex sentences using your approach.
Remember that multiple variables and genre (male/female) also adds lots of complexity.
The solution is to generate only simple sentences where you have only one variable. This is the case that is supported by
ngettext
.Understand that ngettext is something great and that is something that most commercial i18n frameworks from bug software companies don't even support. Even so it has his limitations, so shortly the solution for your question is do split your complex sentence in several simple ones that can be translated using only one variable.