Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Australian 13-numbers do not get correctly formatted. #400

Open
ccg-tim opened this issue May 26, 2021 · 5 comments
Open

Australian 13-numbers do not get correctly formatted. #400

ccg-tim opened this issue May 26, 2021 · 5 comments
Assignees
Labels

Comments

@ccg-tim
Copy link

ccg-tim commented May 26, 2021

In Australia, 13-smart numbers (different from 1300 numbers, as 13-numbers are 6 digits long) do not correctly get formatted using the AsYouType formatter.

According to the Australian style guide (https://www.stylemanual.gov.au/style-rules-and-conventions/numbers-and-measurements/telephone-numbers) 6 digit 13 numbers should be written like this:

13 33 45

Using the AsYouTypeFormatter from the Google Demo, it gets rendered correctly.

Using libphonenumber-js, it gets rendered as

133345

Google's demo link

https://libphonenumber.appspot.com/phonenumberparser?number=134578&country=AU

Screen Shot 2021-05-26 at 4 07 33 pm
Screen Shot 2021-05-26 at 4 07 22 pm
Screen Shot 2021-05-26 at 4 07 40 pm

@ccg-tim
Copy link
Author

ccg-tim commented May 26, 2021

Note, this has already been reported on issue #297, however, it is important to note that the number format that was shown was for Premium rate SMS - but this issue is not a premium rate SMS number. As shown in the screenshot, it is a SHARED_COST number, similar to 1300-numbers.

Smartnumbers® are 13, 1300 or 1800 telephone numbers. Smartnumbers® include phonewords like 13 CATS (13 2287) and distinctive patterned numbers such as 1300 222 222.

https://www.thenumberingsystem.com.au/

Smartnumbers are catchy numbers. They might:

  • be in a pattern, such as 1300 456 789
  • have double digits, such as 1300 222 222

https://www.acma.gov.au/buy-custom-number

https://github.com/google/libphonenumber/blob/c6277266fba8223cfc610cfb1e999deb9f876d65/resources/PhoneNumberMetadata.xml#L2528-L2541

      <!-- Local-rate (SmartNumbers) are put here because they are a reverse-charge network,
           although they charge a small local call connect fee (around 25c). These start with 13
           or 1300. -->
      <sharedCost>
        <possibleLengths national="6,8,10"/>
        <exampleNumber>1300123456</exampleNumber>
        <nationalNumberPattern>
          13(?:
            00\d{3}|
            45[0-4]
          )\d{3}|
          13\d{4}
        </nationalNumberPattern>
      </sharedCost>

https://github.com/google/libphonenumber/blob/c6277266fba8223cfc610cfb1e999deb9f876d65/resources/PhoneNumberMetadata.xml#L2335-L2340

          <!-- 6-digit variable cost fixed line (toll free, premium rate, shared cost) -->
        <numberFormat pattern="(\d{2})(\d{2})(\d{2})">
          <leadingDigits>13</leadingDigits>
          <format>$1 $2 $3</format>
          <intlFormat>NA</intlFormat>
        </numberFormat>

@catamphetamine
Copy link
Owner

catamphetamine commented May 26, 2021

Hi.
Thanks for the detailed report 👍.
It does help having such details when issues are reported.

I have changed the README description previously to remove the seemingly too complex note about the library not formatting phone numbers with area code omitted:
https://raw.githubusercontent.com/catamphetamine/libphonenumber-js/master/README.md

  • Overall, doesn't support formatting non-"conventional" numbers like numbers with the "area code" omitted. When dialing phone numbers within the same "area", people sometimes skip the "area code", and dial, for example, 456-789 instead of (123) 456-789. Google's libphonenumber supports formatting such numbers (with "area code" omitted) because it is used for dialing on the Android phone operating system. Because libphonenumber-js isn't a phone operating system and it's not used for dialing, it doesn't format such "shortened" phone numbers.

Looks like I should re-add it because you're the first one who has reported something like this, and it happened after I've removed that note.

Don't close this issue though because it will be something that others could see.
I'll update the README on GitLab and on GitHub.
The NPM readme will be updated on next package release.

@ccg-tim
Copy link
Author

ccg-tim commented May 27, 2021

No worries, happy to help :)

This is not a number without an area code. Similar to the 1300 number (https://libphonenumber.appspot.com/phonenumberparser?number=1300555444&country=AU) which does get formatted correctly, the 13 number works in all areas of Australia.

Here is an Aussie ad for good measure :) https://www.youtube.com/watch?v=Y0HchzE-7rM

@catamphetamine
Copy link
Owner

catamphetamine commented May 27, 2021

Here is an Aussie ad for good measure

Cool )

So, to conclude, in Australia there're "mobile" numbers and "landline" numbers (like in any other country).
"Landline" numbers can be written in:

  • The normal form: 1300 975 707 (An Australia-wide landline number)
  • The "alternative" "short" form that is mainly used in ads: 13 00 00 (An alternative Australia-wide landline number)

Source: https://www.stylemanual.gov.au/style-rules-and-conventions/numbers-and-measurements/telephone-numbers

So, considering that this library is made for inputting people's personal phone numbers (mostly mobile) and not for crawling the web for all possible numbers (like Google's library), it doesn't have to format ads numbers because people shouldn't input those in the input field

And if they've bought a fancy shortened number for themselves then they'd have to input a regular number just like all other normal people do. They're no "special", are they.

So we don't consider this a bug, rather a feature.

I've updated the readme note to include a link to this issue.

@catamphetamine
Copy link
Owner

catamphetamine commented May 27, 2021

@ccg-tim Lube Mobile will come to you, just for $300

sss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants