| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2009 Google Inc. | |
| 3 * | |
| 4 * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 * you may not use this file except in compliance with the License. | |
| 6 * You may obtain a copy of the License at | |
| 7 * | |
| 8 * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 * | |
| 10 * Unless required by applicable law or agreed to in writing, software | |
| 11 * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 * See the License for the specific language governing permissions and | |
| 14 * limitations under the License. | |
| 15 */ | |
| 16 | |
| 17 // Definition of protocol buffer for holding metadata for international | |
| 18 // telephone numbers. | |
| 19 // @author Shaopeng Jia | |
| 20 | |
| 21 syntax = "proto2"; | |
| 22 | |
| 23 option java_package = "com.google.i18n.phonenumbers"; | |
| 24 option optimize_for = LITE_RUNTIME; | |
| 25 | |
| 26 package i18n.phonenumbers; | |
| 27 | |
| 28 message NumberFormat { | |
| 29 // pattern is a regex that is used to match the national (significant) | |
| 30 // number. For example, the pattern "(20)(\d{4})(\d{4})" will match number | |
| 31 // "2070313000", which is the national (significant) number for Google London. | |
| 32 // Note the presence of the parentheses, which are capturing groups what | |
| 33 // specifies the grouping of numbers. | |
| 34 required string pattern = 1; | |
| 35 | |
| 36 // format specifies how the national (significant) number matched by | |
| 37 // pattern should be formatted. | |
| 38 // Using the same example as above, format could contain "$1 $2 $3", | |
| 39 // meaning that the number should be formatted as "20 7031 3000". | |
| 40 // Each $x are replaced by the numbers captured by group x in the | |
| 41 // regex specified by pattern. | |
| 42 required string format = 2; | |
| 43 | |
| 44 // This field is a regex that is used to match a certain number of digits | |
| 45 // at the beginning of the national (significant) number. When the match is | |
| 46 // successful, the accompanying pattern and format should be used to format | |
| 47 // this number. For example, if leading_digits="[1-3]|44", then all the | |
| 48 // national numbers starting with 1, 2, 3 or 44 should be formatted using the | |
| 49 // accompanying pattern and format. | |
| 50 // | |
| 51 // The first leadingDigitsPattern matches up to the first three digits of the | |
| 52 // national (significant) number; the next one matches the first four digits, | |
| 53 // then the first five and so on, until the leadingDigitsPattern can uniquely | |
| 54 // identify one pattern and format to be used to format the number. | |
| 55 // | |
| 56 // In the case when only one formatting pattern exists, no | |
| 57 // leading_digits_pattern is needed. | |
| 58 repeated string leading_digits_pattern = 3; | |
| 59 | |
| 60 // This field specifies how the national prefix ($NP) together with the first | |
| 61 // group ($FG) in the national significant number should be formatted in | |
| 62 // the NATIONAL format when a national prefix exists for a certain country. | |
| 63 // For example, when this field contains "($NP$FG)", a number from Beijing, | |
| 64 // China (whose $NP = 0), which would by default be formatted without | |
| 65 // national prefix as 10 1234 5678 in NATIONAL format, will instead be | |
| 66 // formatted as (010) 1234 5678; to format it as (0)10 1234 5678, the field | |
| 67 // would contain "($NP)$FG". Note $FG should always be present in this field, | |
| 68 // but $NP can be omitted. For example, having "$FG" could indicate the | |
| 69 // number should be formatted in NATIONAL format without the national prefix. | |
| 70 // This is commonly used to override the rule from generalDesc. | |
| 71 // | |
| 72 // When this field is missing, a number will be formatted without national | |
| 73 // prefix in NATIONAL format. This field does not affect how a number | |
| 74 // is formatted in other formats, such as INTERNATIONAL. | |
| 75 optional string national_prefix_formatting_rule = 4; | |
| 76 | |
| 77 // This field specifies how any carrier code ($CC) together with the first | |
| 78 // group ($FG) in the national significant number should be formatted | |
| 79 // when formatWithCarrierCode is called, if carrier codes are used for a | |
| 80 // certain country. | |
| 81 optional string domestic_carrier_code_formatting_rule = 5; | |
| 82 } | |
| 83 | |
| 84 message PhoneNumberDesc { | |
| 85 // The national_number_pattern is the pattern that a valid national | |
| 86 // significant number would match. This specifies information such as its | |
| 87 // total length and leading digits. | |
| 88 optional string national_number_pattern = 2; | |
| 89 | |
| 90 // The possible_number_pattern represents what a potentially valid phone | |
| 91 // number for this region may be written as. This is a superset of the | |
| 92 // national_number_pattern above and includes numbers that have the area code | |
| 93 // omitted. Typically the only restrictions here are in the number of digits. | |
| 94 // This could be used to highlight tokens in a text that may be a phone | |
| 95 // number, or to quickly prune numbers that could not possibly be a phone | |
| 96 // number for this locale. | |
| 97 optional string possible_number_pattern = 3; | |
| 98 | |
| 99 // An example national significant number for the specific type. It should | |
| 100 // not contain any formatting information. | |
| 101 optional string example_number = 6; | |
| 102 } | |
| 103 | |
| 104 message PhoneMetadata { | |
| 105 // The general_desc contains information which is a superset of descriptions | |
| 106 // for all types of phone numbers. If any element is missing in the | |
| 107 // description of a specific type in the XML file, the element will inherit | |
| 108 // from its counterpart in the general_desc. Every locale is assumed to have | |
| 109 // fixed line and mobile numbers - if these types are missing in the XML | |
| 110 // file, they will inherit all fields from the general_desc. For all other | |
| 111 // types, if the whole type is missing in the xml file, it will be given a | |
| 112 // national_number_pattern of "NA" and a possible_number_pattern of "NA". | |
| 113 required PhoneNumberDesc general_desc = 1; | |
| 114 required PhoneNumberDesc fixed_line = 2; | |
| 115 required PhoneNumberDesc mobile = 3; | |
| 116 required PhoneNumberDesc toll_free = 4; | |
| 117 required PhoneNumberDesc premium_rate = 5; | |
| 118 required PhoneNumberDesc shared_cost = 6; | |
| 119 required PhoneNumberDesc personal_number = 7; | |
| 120 required PhoneNumberDesc voip = 8; | |
| 121 required PhoneNumberDesc pager = 21; | |
| 122 required PhoneNumberDesc uan = 25; | |
| 123 // The rules here distinguish the numbers that are only able to be dialled | |
| 124 // nationally. | |
| 125 required PhoneNumberDesc no_international_dialling = 24; | |
| 126 | |
| 127 // The ISO 3166-1 alpha-2 representation of a country/region | |
| 128 required string id = 9; | |
| 129 | |
| 130 // The country calling code that one would dial from overseas when trying to | |
| 131 // dial a phone number in this country. For example, this would be "64" for | |
| 132 // New Zealand. | |
| 133 required int32 country_code = 10; | |
| 134 | |
| 135 // The international_prefix of country A is the number that needs to be | |
| 136 // dialled from country A to another country (country B). This is followed | |
| 137 // by the country code for country B. Note that some countries may have more | |
| 138 // than one international prefix, and for those cases, a regular expression | |
| 139 // matching the international prefixes will be stored in this field. | |
| 140 required string international_prefix = 11; | |
| 141 | |
| 142 // If more than one international prefix is present, a preferred prefix can | |
| 143 // be specified here for out-of-country formatting purposes. If this field is | |
| 144 // not present, and multiple international prefixes are present, then "+" | |
| 145 // will be used instead. | |
| 146 optional string preferred_international_prefix = 17; | |
| 147 | |
| 148 // The national prefix of country A is the number that needs to be dialled | |
| 149 // before the national significant number when dialling internally. This | |
| 150 // would not be dialled when dialling internationally. For example, in New | |
| 151 // Zealand, the number that would be locally dialled as 09 345 3456 would be | |
| 152 // dialled from overseas as +64 9 345 3456. In this case, 0 is the national | |
| 153 // prefix. | |
| 154 optional string national_prefix = 12; | |
| 155 | |
| 156 // The preferred prefix when specifying an extension in this country. This is | |
| 157 // used for formatting only, and if this is not specified, a suitable default | |
| 158 // should be used instead. For example, if you wanted extensions to be | |
| 159 // formatted in the following way: | |
| 160 // 1 (365) 345 445 ext. 2345 | |
| 161 // " ext. " should be the preferred extension prefix. | |
| 162 optional string preferred_extn_prefix = 13; | |
| 163 | |
| 164 // This field is used for cases where the national prefix of a country | |
| 165 // contains a carrier selection code, and is written in the form of a | |
| 166 // regular expression. For example, to dial the number 2222-2222 in | |
| 167 // Fortaleza, Brazil (area code 85) using the long distance carrier Oi | |
| 168 // (selection code 31), one would dial 0 31 85 2222 2222. Assuming the | |
| 169 // only other possible carrier selection code is 32, the field will | |
| 170 // contain "03[12]". | |
| 171 // | |
| 172 // When it is missing from the XML file, this field inherits the value of | |
| 173 // national_prefix, if that is present. | |
| 174 optional string national_prefix_for_parsing = 15; | |
| 175 | |
| 176 // This field is only populated and used under very rare situations. | |
| 177 // For example, mobile numbers in Argentina are written in two completely | |
| 178 // different ways when dialed in-country and out-of-country | |
| 179 // (e.g. 0343 15 555 1212 is exactly the same number as +54 9 343 555 1212). | |
| 180 // This field is used together with national_prefix_for_parsing to transform | |
| 181 // the number into a particular representation for storing in the phonenumber | |
| 182 // proto buffer in those rare cases. | |
| 183 optional string national_prefix_transform_rule = 16; | |
| 184 | |
| 185 // Specifies whether the mobile and fixed-line patterns are the same or not. | |
| 186 // This is used to speed up determining phone number type in countries where | |
| 187 // these two types of phone numbers can never be distinguished. | |
| 188 optional bool same_mobile_and_fixed_line_pattern = 18 [default=false]; | |
| 189 | |
| 190 // Note that the number format here is used for formatting only, not parsing. | |
| 191 // Hence all the varied ways a user *may* write a number need not be recorded | |
| 192 // - just the ideal way we would like to format it for them. When this element | |
| 193 // is absent, the national significant number will be formatted as a whole | |
| 194 // without any formatting applied. | |
| 195 repeated NumberFormat number_format = 19; | |
| 196 | |
| 197 // This field is populated only when the national significant number is | |
| 198 // formatted differently when it forms part of the INTERNATIONAL format | |
| 199 // and NATIONAL format. A case in point is mobile numbers in Argentina: | |
| 200 // The number, which would be written in INTERNATIONAL format as | |
| 201 // +54 9 343 555 1212, will be written as 0343 15 555 1212 for NATIONAL | |
| 202 // format. In this case, the prefix 9 is inserted when dialling from | |
| 203 // overseas, but otherwise the prefix 0 and the carrier selection code | |
| 204 // 15 (inserted after the area code of 343) is used. | |
| 205 repeated NumberFormat intl_number_format = 20; | |
| 206 | |
| 207 // This field is set when this country is considered to be the main country | |
| 208 // for a calling code. It may not be set by more than one country with the | |
| 209 // same calling code, and it should not be set by countries with a unique | |
| 210 // calling code. This can be used to indicate that "GB" is the main country | |
| 211 // for the calling code "44" for example, rather than Jersey or the Isle of | |
| 212 // Man. | |
| 213 optional bool main_country_for_code = 22 [default=false]; | |
| 214 | |
| 215 // This field is populated only for countries or regions that share a country | |
| 216 // calling code. If a number matches this pattern, it could belong to this | |
| 217 // region. This is not intended as a replacement for IsValidForRegion, and | |
| 218 // does not mean the number must come from this region (for example, 800 | |
| 219 // numbers are valid for all NANPA countries.) This field should be a regular | |
| 220 // expression of the expected prefix match. | |
| 221 optional string leading_digits = 23; | |
| 222 | |
| 223 // The leading zero in a phone number is meaningful in some countries (e.g. | |
| 224 // Italy). This means they cannot be dropped from the national number when | |
| 225 // converting into international format. If leading zeros are possible for | |
| 226 // valid international numbers for this region/country then set this to true. | |
| 227 // This only needs to be set for the region that is the main_country_for_code | |
| 228 // and all regions associated with that calling code will use the same | |
| 229 // setting. | |
| 230 optional bool leading_zero_possible = 26 [default=false]; | |
| 231 } | |
| 232 | |
| 233 message PhoneMetadataCollection { | |
| 234 repeated PhoneMetadata metadata = 1; | |
| 235 } | |
| OLD | NEW |