-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add national formatting of numbers. #83
Conversation
|
b0dbf84
to
ed2909e
Compare
ed2909e
to
5e6d151
Compare
5e6d151
to
f3f0f54
Compare
As with the other PR, I've reworked this to add a new formatter (and a helper function). Hope that's more in line with what you're after. |
Thanks, this looks good. A few comments. Do you think that the NationallyPreferred formatter should be renamed to something like NationallyPreferredIntl? It's a bit of a mouthful but I think it makes the difference between that and National a bit clearer. Second, I'm not convinced that Third, I wonder if there's some useful overlap with the None of these are show-stoppers, but I'd like to at least discuss them before I merge and fiddle about with them. |
Certainly happy to rename the formatter sure, I also couldn't think of anything nicer.
|
OK, that makes sense. Can you write a few lines of doco for |
This adds a new formatter, 'National', that outputs the number in national format using the stored nationalPrefixFormattingRule to work out what to display. It also adds to StubCountry a format_for_country function; supplying a country code (text or number) will output the number in national format if it is in that county, international format otherwise.
f3f0f54
to
eaf938c
Compare
Done, thanks :) |
Merged. I've done a bit of fiddling as discussed. I also made format_for_country and the two new formatters work even if the object being formatted doesn't have the requisite data, by just temporarily instantiating a stub object if necessary. It's a hack, but at least the functionality is available no matter how objects are created. |
This adds a new National formatter that outputs the number in national format, using stored nationalPrefixFormattingRule to work out what to display.
It also adds a
format_for_country
function that will then return national format if in same country, international otherwise.As well as standard usage such as being able to show UK numbers as 020...., one important example is Argentina, where the international number
+54 9 11 1234-5678
is the national number011 15-1234-5678
(9 removed, 15 is added between area code and local code).(This builds upon #80, with one commit on top of that PR.) Fixes #79.