Hi.

It's awesome to see some progress on this. You are aware of the Gettext manual at http://www.gnu.org/software/gettext/manual/gettext.html#Plural-forms right?


Stephan Richter wrote:
On Wednesday 16 July 2008, Lennart Regebro wrote:
While talking about this, what would a ZPT implementation of this best
look like? An i18n:count statement that takes expressions?

   <p i18n:translate="" i18n:count="view/file_count">There are %d files</p>

Or?

Good question! The ZPT above is not correct; once we write a correct one, it becomes more obvious:

<p i18n:translate="">There are <span tal:content="view/num" i18n:name="num" i18n:count="view/num">10</span> files.</p>

Alternatively we could just evaluate the tal:content or tal:replace expression.

So here's a set of additional use-cases:

<p i18n:translate="">
You selected the book called
<span tal:content="title" i18n:name="title">Python for dummies</span>.
</p>

In this case, the i18n:name shouldn't be treated as a number, so I think we need an explicit statement like i18n:count to signal this. We could have the i18n:count default to taking the expression if it is empty.


<p i18n:translate="">
You have to pay
<span tal:content="view/formatted_amount" i18n:name="amount" i18n:count="view/amount">6 dollars</span>.
</p>

In this case the underlying value is a simple integer, but the actual presentation might be locale dependent, like currency formatting.


<p i18n:translate="">
You selected
<span tal:content="num" i18n:name="num">5</span>
out of
<span tal:content="total" i18n:name="total">10</span>
files.
</p>

I'm not sure what to do with this actually. How does multiple numbers in the same sentence are handled? I think this is just not allowed and should cause a syntax error, as there's no general way to translate those sentences with Gettext. Or does it result in a n-dimensional matrix?

<br i18n:attributes="">
You selected
<span tal:content="num" i18n:name="num">5</span>
out of
<span tal:content="total" i18n:name="total">10</span>
files.
</p>


Can someone think about an example involving i18n:attributes? In TAL I cannot construct a dynamic one it seems.


How does this behave in regard to zope.i18nmessageid?

from zope.i18nmessageid import MessageFactory
_ = MessageFactory('domain')


mapping=dict(num=10)
foo = _(u'There are ${num} files.', mapping=mapping)


mapping=dict(num=10, name='/foo/bar')
foo = _(u'There are ${num} files in the folder named ${name}.', mapping=mapping)


So I think we need to signal to the messageid which variable in the mapping is significant for the i18n count, right?

Hanno

_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )

Reply via email to