用两个复数词对句子进行国际化

用两个复数词对句子进行国际化

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

问题描述

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

对于#NUMADULTS位成年人和#NUMCHILDREN位儿童,从#AVAILABILITYFROM到#AVAILABILITYTO"

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

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

09-02 14:37