Translating plurals #70

Open
umpirsky opened this Issue Nov 1, 2012 · 2 comments

3 participants

@umpirsky

According to docs plural translations should be defined as:

{% trans %}
    I have one apple.
{% plural apple_count %}
    I have {{ count }} apples.
{% endtrans %}

I'm using Twig Gettext Extractor to extract translations (it just forces twig to loadTemplate), but for some reason, variables are extracted like %count% instead {{ count }}, which produces untranslated messages.

I tried changing template to:

{% trans %}
    I have one apple.
{% plural apple_count %}
    I have %coun% apples.
{% endtrans %}

but then %coun% is not replaced with actual variable value.

I used transhoice and it worked, but I like this plural tag more because it has better poedit integration.

More then that, when I enable Twig_Extensions_Extension_I18n in my Silex app $app['twig']->addExtension(new \Twig_Extensions_Extension_I18n()) I get:

Warning: gettext() expects exactly 1 parameter, 3 given in resources/cache/twig/70/d7/fd80c73ce0b5c01ac2dc57367f74.php on line 401

Part of d7/fd80c73ce0b5c01ac2dc57367f74.php:

echo ">";
echo twig_escape_filter($this->env, gettext($this->getContext($context, "label"), array(), $this->getContext($context, "translation_domain")), "html", null, true); // #401
echo "</label>

This warning happens for each label translated in my form.

@nlegoff

Hello,

I've got the same behavior concerning the Twig_Extensions_Extension_I18n when labels are translated in a form using
the default theme form_div_layout.html.twig

{{ label|trans({}, translation_domain) }}
@stof

@nlegoff the form theme shipped in Symfony expects the TranslationExtension available in the Symfony bridge, not the Twig_Extensions_Extension_I18n. The interface is not the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment