# NormalizedToLocalized

This filter is the reverse of the filter `Zend_Filter_LocalizedToNormalized` and will change any given normalized input to it's localized representation. It uses in Background `Zend_Locale` to do this transformation for you.

This allows you to give your user any stored normalised value in a localized manner, your user is more common to.

Please note that localization is not equal to translation. This filter can not translate strings from one language into another like you could expect with months or names of days.

The following input types can be localized:

- integer: Integer numbers, which are normalized, will be localized to the set notation.

- float: Float numbers, which are normalized, will be localized to the set notation.

- numbers: Other numbers, like real, will be localized to the set notation.

- time: Time values, will be localized to a string.

- date: Date values, will be normalized to a string.

Any other input will be returned as it, without changing it.

## Localization for numbers

Any given number like integer, float or real value, can be localized. Note, that numbers in scientific notation, can actually not be handled by this filter.

So how does localization work in detail for numbers:

    // Initiate the filter
    $filter = new Zend_Filter_NormalizedToLocalized();
    $filter->filter(123456.78);
    // returns the value '123.456,78'

Let's expect you have set the locale 'de' as application wide locale. `Zend_Filter_NormalizedToLocalized` will take the set locale and use it to detect which sort of output you want to have. In our example it was a value with precision. Now the filter will return you the localized representation for this value as string.

You can also control how your localized number has to look like. Therefor you can give all options which are also used by `Zend_Locale_Format`. The most common are:

- date_format

- locale

- precision

For details about how these options are used take a look into this Zend_Locale chapter.

Below is a example with defined precision so you can see how options work:

    // Numeric Filter
    $filter = new Zend_Filter_NormalizedToLocalized(array('precision' => 2));

    $filter->filter(123456);
    // returns the value '123.456,00'

    $filter->filter(123456.78901);
    // returns the value '123.456,79'

## Localization for date and time

Normalized for date and time values can also be localized. All given date and time values will be returned as string, with the format defined by the set locale.

    // Initiate the filter
    $filter = new Zend_Filter_NormalizedToLocalized();
    $filter->filter(array('day' => '12', 'month' => '04', 'year' => '2009');
    // returns '12.04.2009'

Let's expect you have set the locale 'de' again. Now the input is automatically detected as date, and will be returned in the format defined by the locale 'de'.

Of course you can also control how your date input looks like with the date_format, and the locale option.

    // Date Filter
    $filter = new Zend_Filter_LocalizedToNormalized(
        array('date_format' => 'ss:mm:HH')
    );

    $filter->filter(array('hour' => '33', 'minute' => '22', 'second' => '11'));
    // returns '11:22:33'