View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

{zone-data:component-name}
Zend_Filter_Localize / Zend_Filter_Normalize
{zone-data}

{zone-data:proposer-list}
[~thomas]
{zone-data}

{zone-data:liaison}
[~matthew]
{zone-data}

{zone-data:revision}
1.0 - 24 January 2009: Initial Draft.
{zone-data}

{zone-data:overview}
Zend_Filter_Localize and it's cousine Zend_Filter_Normalize are filters for localizing / normalizing input.
{zone-data}

{zone-data:references}
* [Zend_Locale|http://framework.zend.com/manual/en/Zend_Locale.html]
{zone-data}

{zone-data:requirements}
* Zend_Filter_Localize *will* localize given normalized input to a user locale
* Zend_Filter_Normalize *will* normalize given localized user input to a normalized notation
* Both components *will* ONLY handle numbers, integer, float and dates
* This components *will not* automatically translate any content as f.e. cities, daynames and so on
{zone-data}

{zone-data:dependencies}
* Zend_Exception
* Zend_Locale
{zone-data}

{zone-data:operation}
Zend_Filter_Localize and Zend_Filter_Normalize are nearly related but will act reverse from each other.
Zend_Filter_Normalize acts as normalization filter and converts any given localized input from a user
into a normalized representation. So a user can for example give '1.234,50' and the filter will return
the normalized representation '1234.50' with which the application can do further processing, like storing
into a database. This allows multilingual applications to work internally with a fixed representation and
still allows users to provide localized inputs.

Zend_Filter_Localize works the same way as Zend_Filter_Normalize but reversed. It converts a normalized value
into a localized representation. So, for example, a normalized '1234.50' input from a database can be
displayed to the user in a localized representation and he would get '1.234,50'.

Both components make use of Zend_Locale_Format and are able to work with:
* Numbers
* Integers
* Real Point Values (Floats without scientific notation)
* Dates
* Times
* Currencies

Both components WILL NOT do any translations like daynames, monthnames, cities and so on.
{zone-data}

{zone-data:milestones}
* Milestone 1: \[DONE\] Proposal finished
* Milestone 2: \[DONE\] Proposal accepted
* Milestone 3: \[DONE\] Working implementation
* Milestone 4: \[DONE\] Unit tests
* Milestone 5: \[DONE\] Documentation
* Milestone 6: \[DONE\] Moved to core
{zone-data}

{zone-data:class-list}
* Zend_Filter_Localize
* Zend_Filter_Normalize
{zone-data}

{zone-data:use-cases}
||UC-01||
Normalize given input to english notation
Autodetect the given valuetype
Uses the application wide locale as locale to use (de in this case)
{code}
$filter = new Zend_Filter_Normalize();
$output = $filter->filter('1.234,50');
// returns 1,234.50
{code}

||UC-02||
Normalize the given input to english notation
Input is fixed to date, which does not autodetect
Uses the locale 'de' as defined
{code}
$filter = new Zend_Filter_Normalize('date', 'de');
$output = $filter->filter('12.April.2008');
// returns ISO date notation '2008-04-12T00:00:00 +01:00' as no format is defined
{code}
of course also array notation is supported
{code}
$filter = new Zend_Filter_Normalize(array('type' => 'date', 'locale' => 'de'));
$output = $filter->filter('12.April.2008');
// returns ISO date notation '2008-04-12T00:00:00 +01:00' as no format is defined
{code}

||UC-03||
Localizes a normal input to a localized notation
Autodetect the given valuetype
Uses the application wide locale as locale to use (de in this case)
{code}
$filter = new Zend_Filter_Localize();
$output = $filter->filter('1,234.50');
// returns 1.234,50
{code}

{zone-data}

{zone-data:skeletons}
{code}
class Zend_Filter_Localize
{
public function __constructor($type = null, $locale = null)
{
}

public function filter($value)
{
}
}

class Zend_Filter_Normalize
{
public function __constructor($type = null, $locale = null)
{}

public function filter($value)
{}
}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>