3. Component Requirements, Constraints, and Acceptance Criteria
This component will convert numeric input to conform a specified phone number format.
This component will support national and international formats.
This component will support definition of propritary formats.
This component will provide and use the same API as Zend_Validate_Phone
4. Dependencies on Other Framework Components
Zend_Filter
Zend_Filter_Exception
5. Theory of Operation
This components changes a given input so it conforms a given phone number format. You could give a number and convert it into an international format or a national format simply by changing one spezifier. You could also seperate the different number tokens of which a phone number consists.
<p>I was coming now to add a new proposal for Zend_Locale_Phone and found this proposal while I was searching if someone already did submit one and I found this proposal. I don't know if what I was thinking about can be added to one of your Phone proposals or it can just be a new class [Zend_Locale_Phone]. so I need some guidance.</p>
<p>I was thinking about a class than can </p>
<p>- take a localized phone number and normalize it like converting +20 10 1234567 to 20101234567<br />
the passed phone number could be of any kind of format<br />
take localized number and reformat it to a any chosen format<br />
take a phone number and try to get its country like taking +20 10 1234567 and returning EG.<br />
I did already did work on this one and this was the start of my idea about the proposal<br />
return country code [ 1, 20 ] by locale [US, EG ..]<br />
return locale(s) by country code (this can be kind of tricky as countries like US & CA use the same country code [1] ).</p>
<p>I don't know if these can make a new class or not, but anyway I will be glad to help with these classes under your lead. I'm working now in a telecommunication company on a project that all about phone numbers [mainly SMS], so this is what I do daily anyway.</p>
<p>The trouble with the same country code probably could be circumvented when taking the area code into account.<br />
This I think would also be necessary when estimating locales for countries that use more than one locale as switzerland for instance where you would return fr_CH, de_CH, it_CH or rm_CH according to the area-code.</p>
<p>Great, I don't know if there is an organization that can provide us with accurate and updated area codes for all countries, but anyway we still have <a href="http://en.wikipedia.org/wiki/Category:Telephone_numbers_by_country" title="Telephone numbers by country">the list provided by Wikipedia</a>.</p>
<p>about countries with many locales, we can just use the second part [country/region] as the the first part is the [language] . so for Switzerland we will return [CH] without the language.</p>
<p>Area codes within a country are always declared by the country itself.<br />
There is no international or other organisation which can provide this information.</p>
<p>You can of course get a list from a provider (I have such data and access) but this information can never be complete as it's information which changes every month. Many countries don't even have an organisation where you can get such informations.</p>
<p>Regarding locale and country: this is no problem in reallity.</p>
<p>Zend_Locale_Phone is already in progress. It is an extension on the provided data like the plural rules which are also locale data. There is no need to make an extra proposal for this additional data because Zend_Locale_Phone will not change numbers.</p>
<p>Therefor this proposal has been added. But as this proposal has not beed accepted for now, I am also not working on it.</p>
<p>In sum there are 3 components which are needed to work on phone numbers.<br />
Zend_Locale which provides that needed number informations. No proposal needed.<br />
Zend_Validator_Phone which validates phone numbers. Already accepted.<br />
Zend_Filter_Phone which normalizes, localizes and changes phone numbers. Not accepted for now.</p>
<p>When the last component has been accepted I am able to start my work. Until then you may have to wait.</p>
<p>The information you described is a combination of Locale and Filter.</p>
<p>great work, this is all what I wanted to know. I will wait till the final proposal is accepted and will be glad to help with testing and reporting issues.</p>
<p>It would for example not be possible to revert your result to 1 (xxx) yyy again without knowing the country. Therefor the locale (region) is used in the above examples.</p>
<p>I know in the US there are many was to output a phone #. Is there a way to set custom format like ###<span style="text-decoration: line-through;">###</span>#### or (###) ###-#### or ###.###.#### etc..</p>
12 Comments
comments.show.hideDec 01, 2009
Joó Ádám
<p>Much needed!</p>
Jul 20, 2010
Ahmed Shreef
<p>I was coming now to add a new proposal for Zend_Locale_Phone and found this proposal while I was searching if someone already did submit one and I found this proposal. I don't know if what I was thinking about can be added to one of your Phone proposals or it can just be a new class [Zend_Locale_Phone]. so I need some guidance.</p>
<p>I was thinking about a class than can </p>
<p>- take a localized phone number and normalize it like converting +20 10 1234567 to 20101234567<br />
the passed phone number could be of any kind of format<br />
I did already did work on this one and this was the start of my idea about the proposal<br />
<p>I don't know if these can make a new class or not, but anyway I will be glad to help with these classes under your lead. I'm working now in a telecommunication company on a project that all about phone numbers [mainly SMS], so this is what I do daily anyway.</p>
<p>thanks </p>
Jul 21, 2010
Andreas Heigl
<p>Interesting idea.</p>
<p>The trouble with the same country code probably could be circumvented when taking the area code into account.<br />
This I think would also be necessary when estimating locales for countries that use more than one locale as switzerland for instance where you would return fr_CH, de_CH, it_CH or rm_CH according to the area-code.</p>
<p>Not sure whether that would work though.</p>
Jul 21, 2010
Ahmed Shreef
<p>Great, I don't know if there is an organization that can provide us with accurate and updated area codes for all countries, but anyway we still have <a href="http://en.wikipedia.org/wiki/Category:Telephone_numbers_by_country" title="Telephone numbers by country">the list provided by Wikipedia</a>.</p>
<p>about countries with many locales, we can just use the second part [country/region] as the the first part is the [language] . so for Switzerland we will return [CH] without the language.</p>
Jul 24, 2010
Thomas Weidner
<p>Area codes within a country are always declared by the country itself.<br />
There is no international or other organisation which can provide this information.</p>
<p>You can of course get a list from a provider (I have such data and access) but this information can never be complete as it's information which changes every month. Many countries don't even have an organisation where you can get such informations.</p>
<p>Regarding locale and country: this is no problem in reallity.</p>
Jul 24, 2010
Thomas Weidner
<p>Zend_Locale_Phone is already in progress. It is an extension on the provided data like the plural rules which are also locale data. There is no need to make an extra proposal for this additional data because Zend_Locale_Phone will not change numbers.</p>
<p>Therefor this proposal has been added. But as this proposal has not beed accepted for now, I am also not working on it.</p>
<p>In sum there are 3 components which are needed to work on phone numbers.<br />
Zend_Locale which provides that needed number informations. No proposal needed.<br />
Zend_Validator_Phone which validates phone numbers. Already accepted.<br />
Zend_Filter_Phone which normalizes, localizes and changes phone numbers. Not accepted for now.</p>
<p>When the last component has been accepted I am able to start my work. Until then you may have to wait.</p>
<p>The information you described is a combination of Locale and Filter.</p>
Jul 24, 2010
Ahmed Shreef
<p>great work, this is all what I wanted to know. I will wait till the final proposal is accepted and will be glad to help with testing and reporting issues.</p>
<p>regards</p>
Jul 28, 2010
Dolf Schimmel (Freeaqingme)
<p>Can it also be used 'in reverse'? Meaning that when i input 1 (257) 12345 - 67 i get as result: 2571234567?</p>
Jul 30, 2010
Thomas Weidner
<p>Not in all cases but normally yes.</p>
<p>It would for example not be possible to revert your result to 1 (xxx) yyy again without knowing the country. Therefor the locale (region) is used in the above examples.</p>
Jul 28, 2010
Shaun Farrell
<p>I know in the US there are many was to output a phone #. Is there a way to set custom format like ###<span style="text-decoration: line-through;">###</span>#### or (###) ###-#### or ###.###.#### etc..</p>
<p>What about phone extensions?</p>
Jul 30, 2010
Thomas Weidner
<p>As you can see in the above "usecase 3" extensions are supported.</p>
Aug 03, 2010
Shaun Farrell
<ac:macro ac:name="note"><ac:rich-text-body><p><strong>Community Review Team Recommendation</strong></p>
<p>The CR Team advises that this proposal be approved.</p></ac:rich-text-body></ac:macro>