title: Twig DateExtension translation
body: <p>I try to add translation for Twig DateExtension in my Silex application. Here is what I did for now.</p>
  
  <p>First I added the requested components in my composer.json</p>
  
  <pre>
  "twig/twig": "^1.22",  
  "twig/extension": "^1.3",  
  "symfony/twig-bridge": "^2.7",  
  "symfony/translation": "^2.7",  
  "symfony/config": "^2.7",  
  "symfony/yaml": "^2.7",  
  </pre>
  
  <p>Then I register services like this:</p>
  
  <pre><code>&lt;?php
  $app-&gt;register(new Silex\Provider\TwigServiceProvider(), array(
      'twig.path' =&gt; __DIR__.'/../views',
  ));
  
  $app-&gt;register(new Silex\Provider\TranslationServiceProvider(), array(
      'locale_fallbacks' =&gt; array('en'),
      'locale' =&gt; 'fr_FR'
  ));
  $app['translator'] = $app-&gt;share($app-&gt;extend('translator', function($translator, $app) {
      $translator-&gt;addLoader('yaml', new Symfony\Component\Translation\Loader\YamlFileLoader());
      $translator-&gt;addResource('yaml', __DIR__.'/../src/locales/fr.yml', 'fr_FR');
  
      return $translator;
  }));
  
  $app['twig'] = $app-&gt;share($app-&gt;extend('twig', function(Twig_Environment $twig, $app) {
      $twig-&gt;addExtension(new Twig_Extensions_Extension_Text());
      $twig-&gt;addExtension(new Twig_Extensions_Extension_Date($app['translator']));
      return $twig;
  }));
  </code></pre>
  
  <p>In my fr.yml I try to put translation like this:</p>
  
  <pre><code>diff.ago.day: Il y a %count% jour|Il y a %count% jours
  test: converted
  </code></pre>
  
  <p>This configuration seems to be partially working because in my template I have (where foo is a DateTime):</p>
  
  <pre><code>{{ foo|time_diff }} - {{ "test"|trans }}
  </code></pre>
  
  <p>The result should be:</p>
  
  <pre><code>Il y a 1 jour - converted
  </code></pre>
  
  <p>But it's:</p>
  
  <pre><code>diff.ago.day - converted
  </code></pre>
  
  <p>So the first part isn't converted while the second one is.</p>
  
  <p>Where is my mistake ?</p>
  
  <p>Thanks a lot.</p>
  
  <p>EDIT:</p>
  
  <p>I finally found my mistake. After digging into Symfony code, I found they use a special domain for translation: 'date'.
  So I add a forth parameter to my ressource loading in order to tell it.</p>
  
  <p>The new loading line is now:</p>
  
  <pre><code>$translator-&gt;addResource('yaml', __DIR__.'/../src/locales/fr.yml', 'fr_FR', 'date');
  </code></pre>