[RFC][WIP] filters and helpers for localized formatting

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: documentation, implementation of number formatting

[![Build Status](https://secure.travis-ci.org/eriksencosta/symfony.png?branch=locale-dev)](http://travis-ci.org/eriksencosta/symfony)

symfony 1 had some [useful helpers](http://www.symfony-project.org/gentle-introduction/1_4/en/13-I18n-and-L10n#chapter_13_sub_outputting_data_in_the_user_s_culture) for localization. This RFC proposes the porting of some of those helpers to Symfony2. It's a simple feature that I missed and that I think is simple yes helpful. The [bcc/extra-tools-bundle](https://github.com/michelsalib/BCCExtraToolsBundle) have a Twig filter for date formatting and another for country display (but none for the PHP engine).

This initial implementation includes the formatters as Twig filters and PHP helpers:

 - `formatCurrency`
 - `formatDate`
 - `formatTime`
 - `formatDateTime`

This is a WIP and I want some feedback to make the API cleaner and to improve the naming (if this RFC get approved). I implemented the filters and helpers with every parameter hardcoded in the methods' signatures. I made this choice to maintain consistent with the others filters and helpers implementations. This made the date/time a little bit hard to use but this is easy to refactor:

    // this (none to: dateStyle, timeStyle, calendar and timeZone - in this order)
    date|formatDateTime(none, none, none, none, 'yyyy.MM.dd HH:mm:ss a', 'fr_FR')

    // could become:
    date|formatDateTime({ 'pattern' : 'yyyy.MM.dd HH:mm:ss a' }, 'fr_FR')

    // or:
    date|formatDateTime('fr_FR', { 'pattern' : 'yyyy.MM.dd HH:mm:ss a' })

Another thing I am not sure is about the service configuration. The `twig.extension.locale` depends on a service defined in FrameworkBundle (like `twig.extension.trans`) but the TwigBundle does not declare FrameworkBundle as a dependency. Also, naming deserves some love here too.

Examples:
--

Controller:

```php
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class LocaleController extends Controller
{
    /**
     * @Route("/locale/{format}", defaults={ "format"="twig" })
     */
    public function indexAction($format)
    {
        return $this->render(
            'VendorSomeBundle:Locale:index.html.'.$format,
            array('date' => new \DateTime('2012-07-10'), 'amount' => 125.50)
        );
    }
}
```

Twig example:

```html
<!-- src/Vendor/SomeBundle/Resources/views/Locale/index.html.twig -->
<h2>Currencies</h2>
<p>Default</p>
<ul>
    <li>Using app global currency: {{ amount|formatCurrency() }}</li>
    <li>BRL currency: {{ amount|formatCurrency('BRL') }}</li>
</ul>

<p>Locale</p>
<ul>
   <li>Using app global currency: {{ amount|formatCurrency(none, 'pt_BR') }}</li>
   <li>BRL currency: {{ amount|formatCurrency('BRL', 'pt_BR') }}</li>
</ul>

<h2>Dates</h2>
<p>Default</p>
<ul>
    <li>date: {{ date|formatDate() }}</li>
    <li>time: {{ date|formatTime() }}</li>
    <li>datetime: {{ date|formatDateTime() }}</li>
</ul>

<p>Date/time style</p>
<ul>
    <li>date: {{ date|formatDate('full') }}</li>
    <li>time: {{ date|formatTime('full') }}</li>
    <li>datetime: {{ date|formatDateTime('full', 'full') }}</li>
</ul>

<p>Timezone</p>
<ul>
    <li>date: {{ date|formatDate(none, 'Europe/London') }}</li>
    <li>time: {{ date|formatTime(none, 'Europe/London') }}</li>
    <li>datetime: {{ date|formatDateTime(none, none, 'Europe/London') }}</li>
</ul>

<p>Calendar</p>
<ul>
    <li>date: {{ date|formatDate(none, none, 'traditional') }}</li>
    <li>time: {{ date|formatTime(none, none, 'traditional') }}</li>
    <li>datetime: {{ date|formatDateTime(none, none, none, 'traditional') }}</li>
</ul>

<p>Pattern</p>
<ul>
    <li>date: {{ date|formatDate(none, none, none, 'HH:mm:ss a') }}</li>
    <li>time: {{ date|formatTime(none, none, none, 'yyyy.MM.dd') }}</li>
    <li>datetime: {{ date|formatDateTime(none, none, none, none, 'yyyy.MM.dd HH:mm:ss a') }}</li>
</ul>
```

PHP example:
--

```php
<!-- src/Vendor/SomeBundle/Resources/views/Locale/index.html.php -->
<h2>Currencies</h2>
<p>Default</p>
<ul>
    <li>config: <?php echo $view['locale']->formatCurrency($amount) ?></li>
    <li>BRL: <?php echo $view['locale']->formatCurrency($amount, 'BRL') ?></li>
</ul>

<p>Locale</p>
<ul>
    <li>config: <?php echo $view['locale']->formatCurrency($amount, null, 'pt_BR') ?></li>
    <li>BRL: <?php echo $view['locale']->formatCurrency($amount, 'BRL', 'pt_BR') ?></li>
</ul>

<h2>Dates</h2>
<p>Default</p>
<ul>
    <li>date: <?php echo $view['locale']->formatDate($date) ?></li>
    <li>time: <?php echo $view['locale']->formatTime($date) ?></li>
    <li>datetime: <?php echo $view['locale']->formatDateTime($date) ?></li>
</ul>

<p>Full style</p>
<ul>
    <li>date: <?php echo $view['locale']->formatDate($date, 'full') ?></li>
    <li>time: <?php echo $view['locale']->formatTime($date, 'full') ?></li>
    <li>datetime: <?php echo $view['locale']->formatDateTime($date, 'full', 'full') ?></li>
</ul>

<p>Timezone</p>
<ul>
    <li>date: <?php echo $view['locale']->formatDate($date, null, 'Europe/London') ?></li>
    <li>time: <?php echo $view['locale']->formatTime($date, null, 'Europe/London') ?></li>
    <li>datetime: <?php echo $view['locale']->formatDateTime($date, null, null, 'Europe/London') ?></li>
</ul>

<p>Calendar</p>
<ul>
    <li>date: <?php echo $view['locale']->formatDate($date, null, null, 'traditional') ?></li>
    <li>time: <?php echo $view['locale']->formatTime($date, null, null, 'traditional') ?></li>
    <li>datetime: <?php echo $view['locale']->formatDateTime($date, null, null, null, 'traditional') ?></li>
</ul>

<p>Pattern</p>
<ul>
    <li>date: <?php echo $view['locale']->formatDate($date, null, null, null, 'HH:mm:ss a') ?></li>
    <li>time: <?php echo $view['locale']->formatTime($date, null, null, null, 'yyyy.MM.dd') ?></li>
    <li>datetime: <?php echo $view['locale']->formatDateTime($date, null, null, null, null, 'yyyy.MM.dd HH:mm:ss a') ?></li>
</ul>
```