title: Can I load a Twig template based on the request language?
body: <p>In a recent multi-language project I use Twig to store email templates for different languages. Currently I name the templates with their respective language in the filename (e.g. <code>email_en.txt.twig</code> and load those by concatenation in my controller (example adapted from the <a href="http://symfony.com/doc/current/cookbook/email/email.html#sending-emails" rel="nofollow">Symfony2 documentation</a>):</p>
  
  <pre><code>public function indexAction($name, Request $request)
  {
      $message = \Swift_Message::newInstance()
          -&gt;setSubject('Hello Email')
          -&gt;setFrom('send@example.com')
          -&gt;setTo('recipient@example.com')
          -&gt;setBody(
              $this-&gt;renderView(
                  'HelloBundle:Hello:email_" . $request-&gt;getLocale() . ".txt.twig',
                  array('name' =&gt; $name)
              )
          )
      ;
      $this-&gt;get('mailer')-&gt;send($message);
  
      return $this-&gt;render(...);
  }
  </code></pre>
  
  <p>Now I know I could use a dedicated service or a factory to handle that kind of logic in a more saner way, but I'm keen to find out if this problem has already been tackled by somebody and how it was solved.</p>
  
  <p>[edit] To avoid having this question closed I'll rephrase my question (hopefully to the better). Is it possible to render a twig template based on the request language without using an if-chain or a factory (by some kind of black twig/symfony/configuration/convention/whatever magic)?</p>