Localize Phone Numbers

Post-install, Rock is configured to support only US-formatted phone numbers. When only one country is configured, the phone entry field looks like the example below.

This field can easily be adjusted to support other countries. Simply add country specific formatting fields to the Admin Tools > Settings > Defined Types > Phone Country Code defined type.

Each new entry should have the following values.

  • Value: This is the country code that's used when dialing the number.
  • Description: A short description of the phone formatting pattern.
  • Match Expression: This is a regular expression that's used to match the value you entered and apply the correct formatting to it. For instance, a seven-digit number in the US would match the formatting rule 555-5555 while a 10 digit number would match to (555) 555-5555.
  • Formatting Expression: This string is used to apply the formatting to the matched number. Each grouping of numbers is represented by a $#.

Tip

You can find more information on the formatting of phone numbers for specific countries on Wikipedia.  
We've also started a short list of best practices that have been shared by other Rock community members. You can check them out at http://www.rockrms.com/InternationalPhones.  

Once you add a second country, the phone number field will change a bit in look. You'll notice the addition of a country code selection at the beginning of the input. The phone country code listed at the top of the defined type list will become the default country code, so in the screen shown above grab the hamburger grips to the left of each entry and drag them up and down the list as you desire.

Note

Formatting Phone Numbers on the Person Profile Page
There's a setting on the Bio block used on the Person Profile page that enables the country code to be prepended to all phone numbers. Enabling this setting may help the formatting for many international organizations.