用两个复数词国际化句子 [英] Internationalising sentences with two plural words

查看:19
本文介绍了用两个复数词国际化句子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 gettext 使具有多个数值变量的句子可翻译?ngettext 只接受一个数字作为复数参数.

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

从 #AVAILABILITYFROM 到 #AVAILABILITYTO,适用于 #NUMADULTS 成人和 #NUMCHILDREN 儿童"

"from #AVAILABILITYFROM to #AVAILABILITYTO for #NUMADULTS adult and #NUMCHILDREN child"

推荐答案

语法在英语以外的其他语言中可能非常复杂,您应该意识到使用您的方法生成正确的复杂句子实际上是不可能的.

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.

解决方案是只生成只有一个变量的简单句子.ngettext 支持这种情况.

The solution is to generate only simple sentences where you have only one variable. This is the case that is supported by ngettext.

了解 ngettext 非常棒,而大多数来自 bug 软件公司的商业 i18n 框架甚至都不支持.尽管如此,它也有他的局限性,所以很快你的问题的解决方案就是将你的复杂句子分成几个简单的句子,只用一个变量就可以翻译.

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.

这篇关于用两个复数词国际化句子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆