2010/1/7 Kornel Lesiński <kor...@aardvarkmedia.co.uk>
>        if (false === strpos('${number}', $key))
>        {
>                $value = gettext($key);
>        }
>        else
>        {
>                $value = ngettext($key, $key, $this->_vars['number']);
>        }
> The problem is, as you see, that gettext requires use of a different function 
> for plural form, and TAL syntax has no way to
> indicate when this is needed. I'm open to suggestions.

Kornel, it won't work as first parameter should be "picture" and the
second should be "pictures" (or "${n} pictures" as in OP example). But
from this string:
    <tal:block i18n:translate=""><span i18n:name="n"
tal:replace="data/count"/> pictures</tal:block>
you can't know if given key is plural or singular and what is the other key.

As for suggestions, how about something like this:
    <span i18n:name="n" tal:replace="data/count"/> <tal:block
i18n:translate="picture" i18n:plural="pictures"/>
or this:
    <tal:block i18n:translate="" i18n:singular="picture"><span
i18n:name="n" tal:replace="data/count"/> pictures</tal:block>

Thus from the first example you know the given key is in singular form
and i18n:plural gives you the second key. In the second example you
know everything inside tal:block is given as plural key so you need to
take i18n:singular for the first key.

I'm sorry if my examples seem completely broken or inappropriate as
I'm not familiar with PHPTAL developers' coding style :)


PHPTAL mailing list

Reply via email to