Brazilian format support

danillonunes - March 27, 2009 - 22:47
Project:Phone (CCK)
Version:HEAD
Component:Code
Category:task
Priority:normal
Assigned:danillonunes
Status:closed
Description

Hello, I checkout the CVS head version and code a Brazilian phone format, based on the French .inc file.

This accept the following formats:

  • 55 11 3344 5566
  • 011 3344 5566
  • 11 3344 5566

with optionally any ( ), + and - separators.

I hope you like it.

AttachmentSize
brazilian_phone.patch5.51 KB

#1

develCuy - April 1, 2009 - 03:29
Version:6.x-2.7» HEAD

I have re-rolled the patch for HEAD and added more test cases:
+55 11 888 9999
+55 11 8888 9999
0055 11 888 9999
0055 11 8888 9999
55 11 888 9999
55 11 8888 9999

Notice that some brazilian phone numbers still use 7 digits format.

AttachmentSize
416200-brazilian_phone-2.patch 4.39 KB

#2

danillonunes - April 1, 2009 - 14:16

Apparently you forgot to include the .inc file in your patch.

#3

danillonunes - April 2, 2009 - 14:23

I add options to select separators and use of parentheses in BR phones, like the Canadians.

Also, I make too a patch to 6.x-2.7 version.

Also, now all this formats are valids:

  • 11 888 9999
  • 11 8888 9999
  • 011 888 9999
  • 011 8888 9999
  • 55 11 888 9999
  • 55 11 8888 9999
  • 0055 11 888 9999
  • 0055 11 8888 9999

with optionally any ( ), + and - separators that are irrelevants, the final result is formatted as defined by admin.

Thanks to develCuy for help with regex.

AttachmentSize
phone-br-6.x-2.7.patch 6.41 KB
phone-br-HEAD.patch 6.85 KB

#4

develCuy - April 9, 2009 - 22:17

@danillonunes, I don't agree with your approach. See the implementation for other countries in this module, they don't suppress characters from the text AFAIK.
It is supposed that a validation checks the data, this should not alter the data.
ATM, your patch thinks following phones are valid>

  • 11+888()99(99+
  • 1+1 888)8 9(999
  • 01+1 (888) 9999
  • 011 (8888) 9999
  • 55 11 888 (9999))
  • 55 +11 8888 9999
  • +(0055) 11 888 9999
  • 0055 )(11 8+888 999)9

Those are so far not valid phone numbers.

Here is my patch including the missing file. Please take a look.

Blessings!

AttachmentSize
416200-brazilian_phone-3.patch 5.91 KB

#5

danillonunes - April 16, 2009 - 21:16

develCuy, the implementation of French format, which I uses as basis for developing the Brazilian format, removes too non-numeric separator characters.

It changes the data because it is not just a validation (did you look the format_br_phone_number function?), but a validation followed by a formatting, which ensures that all data received are stored in a standard way - regardless of format they were received (as a validation of URL will accept an address as "google.com" and will change it to "http://google.com").

I don't consider the possibility that the user enters something like "11+888()99(99+". Really, I think it is very improbably that he type it, but if for some reason this really happen, I think it is better that the module can understand and process this information in an intelligent way (it will format it as "(11) 888-9999") than say it is invalid and ask the user to type in the right way - is less work for the user that probably was already fully drunken to have entered something like it. ;)

BTW, I found that the Brazilian phones with 7 digits are already obsolete, now the standard is 8 digits in everywhere. I'm sorry for giving you a wrong information.

#6

thierry_gd - August 26, 2009 - 16:19
Status:needs review» fixed

Taken into account in 6.2.9 version

#7

System Message - September 9, 2009 - 16:20
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.