forked from daviddrysdale/python-phonenumbers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphonemetadata.proto
More file actions
282 lines (251 loc) · 14.1 KB
/
Copy pathphonemetadata.proto
File metadata and controls
282 lines (251 loc) · 14.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/*
* Copyright (C) 2009 The Libphonenumber Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Definition of protocol buffer for holding metadata for international
// telephone numbers. The fields here correspond exactly to those in
// resources/PhoneNumberMetadata.xml.
// @author Shaopeng Jia
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
option java_package = "com.google.i18n.phonenumbers";
package i18n.phonenumbers;
message NumberFormat {
// pattern is a regex that is used to match the national (significant)
// number. For example, the pattern "(20)(\d{4})(\d{4})" will match number
// "2070313000", which is the national (significant) number for Google London.
// Note the presence of the parentheses, which are capturing groups what
// specifies the grouping of numbers.
required string pattern = 1;
// format specifies how the national (significant) number matched by
// pattern should be formatted.
// Using the same example as above, format could contain "$1 $2 $3",
// meaning that the number should be formatted as "20 7031 3000".
// Each $x are replaced by the numbers captured by group x in the
// regex specified by pattern.
required string format = 2;
// This field is a regex that is used to match a certain number of digits
// at the beginning of the national (significant) number. When the match is
// successful, the accompanying pattern and format should be used to format
// this number. For example, if leading_digits="[1-3]|44", then all the
// national numbers starting with 1, 2, 3 or 44 should be formatted using the
// accompanying pattern and format.
//
// The first leadingDigitsPattern matches up to the first three digits of the
// national (significant) number; the next one matches the first four digits,
// then the first five and so on, until the leadingDigitsPattern can uniquely
// identify one pattern and format to be used to format the number.
//
// In the case when only one formatting pattern exists, no
// leading_digits_pattern is needed.
repeated string leading_digits_pattern = 3;
// This field specifies how the national prefix ($NP) together with the first
// group ($FG) in the national significant number should be formatted in
// the NATIONAL format when a national prefix exists for a certain country.
// For example, when this field contains "($NP$FG)", a number from Beijing,
// China (whose $NP = 0), which would by default be formatted without
// national prefix as 10 1234 5678 in NATIONAL format, will instead be
// formatted as (010) 1234 5678; to format it as (0)10 1234 5678, the field
// would contain "($NP)$FG". Note $FG should always be present in this field,
// but $NP can be omitted. For example, having "$FG" could indicate the
// number should be formatted in NATIONAL format without the national prefix.
// This is commonly used to override the rule specified for the territory in
// the XML file.
//
// When this field is missing, a number will be formatted without national
// prefix in NATIONAL format. This field does not affect how a number
// is formatted in other formats, such as INTERNATIONAL.
optional string national_prefix_formatting_rule = 4;
// This field specifies whether the $NP can be omitted when formatting a
// number in national format, even though it usually wouldn't be. For example,
// a UK number would be formatted by our library as 020 XXXX XXXX. If we have
// commonly seen this number written by people without the leading 0, for
// example as (20) XXXX XXXX, this field would be set to true. This will be
// inherited from the value set for the territory in the XML file, unless a
// national_prefix_formatting_rule is defined specifically for this
// NumberFormat.
optional bool national_prefix_optional_when_formatting = 6;
// This field specifies how any carrier code ($CC) together with the first
// group ($FG) in the national significant number should be formatted
// when formatWithCarrierCode is called, if carrier codes are used for a
// certain country.
optional string domestic_carrier_code_formatting_rule = 5;
}
message PhoneNumberDesc {
// The national_number_pattern is the pattern that a valid national
// significant number would match. This specifies information such as its
// total length and leading digits.
optional string national_number_pattern = 2;
// The possible_number_pattern represents what a potentially valid phone
// number for this region may be written as. This is a superset of the
// national_number_pattern above and includes numbers that have the area code
// omitted. Typically the only restrictions here are in the number of digits.
// This could be used to highlight tokens in a text that may be a phone
// number, or to quickly prune numbers that could not possibly be a phone
// number for this locale.
optional string possible_number_pattern = 3;
// An example national significant number for the specific type. It should
// not contain any formatting information.
optional string example_number = 6;
}
message PhoneMetadata {
// The general_desc contains information which is a superset of descriptions
// for all types of phone numbers. If any element is missing in the
// description of a specific type in the XML file, the element will inherit
// from its counterpart in the general_desc. Every locale is assumed to have
// fixed line and mobile numbers - if these types are missing in the
// PhoneNumberMetadata XML file, they will inherit all fields from the
// general_desc. For all other types that are generally relevant to normal
// phone numbers, if the whole type is missing in the PhoneNumberMetadata XML
// file, it will be given a national_number_pattern of "NA" and a
// possible_number_pattern of "NA".
optional PhoneNumberDesc general_desc = 1;
optional PhoneNumberDesc fixed_line = 2;
optional PhoneNumberDesc mobile = 3;
optional PhoneNumberDesc toll_free = 4;
optional PhoneNumberDesc premium_rate = 5;
optional PhoneNumberDesc shared_cost = 6;
optional PhoneNumberDesc personal_number = 7;
optional PhoneNumberDesc voip = 8;
optional PhoneNumberDesc pager = 21;
optional PhoneNumberDesc uan = 25;
optional PhoneNumberDesc emergency = 27;
optional PhoneNumberDesc voicemail = 28;
optional PhoneNumberDesc short_code = 29;
optional PhoneNumberDesc standard_rate = 30;
optional PhoneNumberDesc carrier_specific = 31;
// The rules here distinguish the numbers that are only able to be dialled
// nationally.
optional PhoneNumberDesc no_international_dialling = 24;
// The ISO 3166-1 alpha-2 representation of a country/region, with the
// exception of "country calling codes" used for non-geographical entities,
// such as Universal International Toll Free Number (+800). These are all
// given the ID "001", since this is the numeric region code for the world
// according to UN M.49: http://en.wikipedia.org/wiki/UN_M.49
required string id = 9;
// The country calling code that one would dial from overseas when trying to
// dial a phone number in this country. For example, this would be "64" for
// New Zealand.
optional int32 country_code = 10;
// The international_prefix of country A is the number that needs to be