11767c5feSopenharmony_ci/* 21767c5feSopenharmony_ci * Copyright (C) 2009 The Libphonenumber Authors 31767c5feSopenharmony_ci * 41767c5feSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 51767c5feSopenharmony_ci * you may not use this file except in compliance with the License. 61767c5feSopenharmony_ci * You may obtain a copy of the License at 71767c5feSopenharmony_ci * 81767c5feSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 91767c5feSopenharmony_ci * 101767c5feSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 111767c5feSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 121767c5feSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131767c5feSopenharmony_ci * See the License for the specific language governing permissions and 141767c5feSopenharmony_ci * limitations under the License. 151767c5feSopenharmony_ci */ 161767c5feSopenharmony_ci 171767c5feSopenharmony_ci// Definition of protocol buffer for holding metadata for international 181767c5feSopenharmony_ci// telephone numbers. The fields here correspond exactly to those in 191767c5feSopenharmony_ci// resources/PhoneNumberMetadata.xml. 201767c5feSopenharmony_ci// @author Shaopeng Jia 211767c5feSopenharmony_ci 221767c5feSopenharmony_cisyntax = "proto2"; 231767c5feSopenharmony_ci 241767c5feSopenharmony_cioption optimize_for = LITE_RUNTIME; 251767c5feSopenharmony_ci 261767c5feSopenharmony_cioption java_package = "com.google.i18n.phonenumbers"; 271767c5feSopenharmony_cipackage i18n.phonenumbers; 281767c5feSopenharmony_ci 291767c5feSopenharmony_cimessage NumberFormat { 301767c5feSopenharmony_ci // pattern is a regex that is used to match the national (significant) 311767c5feSopenharmony_ci // number. For example, the pattern "(20)(\d{4})(\d{4})" will match number 321767c5feSopenharmony_ci // "2070313000", which is the national (significant) number for Google London. 331767c5feSopenharmony_ci // Note the presence of the parentheses, which are capturing groups what 341767c5feSopenharmony_ci // specifies the grouping of numbers. 351767c5feSopenharmony_ci required string pattern = 1; 361767c5feSopenharmony_ci 371767c5feSopenharmony_ci // format specifies how the national (significant) number matched by 381767c5feSopenharmony_ci // pattern should be formatted. 391767c5feSopenharmony_ci // Using the same example as above, format could contain "$1 $2 $3", 401767c5feSopenharmony_ci // meaning that the number should be formatted as "20 7031 3000". 411767c5feSopenharmony_ci // Each $x are replaced by the numbers captured by group x in the 421767c5feSopenharmony_ci // regex specified by pattern. 431767c5feSopenharmony_ci required string format = 2; 441767c5feSopenharmony_ci 451767c5feSopenharmony_ci // This field is a regex that is used to match a certain number of digits 461767c5feSopenharmony_ci // at the beginning of the national (significant) number. When the match is 471767c5feSopenharmony_ci // successful, the accompanying pattern and format should be used to format 481767c5feSopenharmony_ci // this number. For example, if leading_digits="[1-3]|44", then all the 491767c5feSopenharmony_ci // national numbers starting with 1, 2, 3 or 44 should be formatted using the 501767c5feSopenharmony_ci // accompanying pattern and format. 511767c5feSopenharmony_ci // 521767c5feSopenharmony_ci // The first leadingDigitsPattern matches up to the first three digits of the 531767c5feSopenharmony_ci // national (significant) number; the next one matches the first four digits, 541767c5feSopenharmony_ci // then the first five and so on, until the leadingDigitsPattern can uniquely 551767c5feSopenharmony_ci // identify one pattern and format to be used to format the number. 561767c5feSopenharmony_ci // 571767c5feSopenharmony_ci // In the case when only one formatting pattern exists, no 581767c5feSopenharmony_ci // leading_digits_pattern is needed. 591767c5feSopenharmony_ci repeated string leading_digits_pattern = 3; 601767c5feSopenharmony_ci 611767c5feSopenharmony_ci // This field specifies how the national prefix ($NP) together with the first 621767c5feSopenharmony_ci // group ($FG) in the national significant number should be formatted in 631767c5feSopenharmony_ci // the NATIONAL format when a national prefix exists for a certain country. 641767c5feSopenharmony_ci // For example, when this field contains "($NP$FG)", a number from Beijing, 651767c5feSopenharmony_ci // China (whose $NP = 0), which would by default be formatted without 661767c5feSopenharmony_ci // national prefix as 10 1234 5678 in NATIONAL format, will instead be 671767c5feSopenharmony_ci // formatted as (010) 1234 5678; to format it as (0)10 1234 5678, the field 681767c5feSopenharmony_ci // would contain "($NP)$FG". Note $FG should always be present in this field, 691767c5feSopenharmony_ci // but $NP can be omitted. For example, having "$FG" could indicate the 701767c5feSopenharmony_ci // number should be formatted in NATIONAL format without the national prefix. 711767c5feSopenharmony_ci // This is commonly used to override the rule specified for the territory in 721767c5feSopenharmony_ci // the XML file. 731767c5feSopenharmony_ci // 741767c5feSopenharmony_ci // When this field is missing, a number will be formatted without national 751767c5feSopenharmony_ci // prefix in NATIONAL format. This field does not affect how a number 761767c5feSopenharmony_ci // is formatted in other formats, such as INTERNATIONAL. 771767c5feSopenharmony_ci optional string national_prefix_formatting_rule = 4; 781767c5feSopenharmony_ci 791767c5feSopenharmony_ci // This field specifies whether the $NP can be omitted when formatting a 801767c5feSopenharmony_ci // number in national format, even though it usually wouldn't be. For example, 811767c5feSopenharmony_ci // a UK number would be formatted by our library as 020 XXXX XXXX. If we have 821767c5feSopenharmony_ci // commonly seen this number written by people without the leading 0, for 831767c5feSopenharmony_ci // example as (20) XXXX XXXX, this field would be set to true. This will be 841767c5feSopenharmony_ci // inherited from the value set for the territory in the XML file, unless a 851767c5feSopenharmony_ci // national_prefix_optional_when_formatting is defined specifically for this 861767c5feSopenharmony_ci // NumberFormat. 871767c5feSopenharmony_ci optional bool national_prefix_optional_when_formatting = 6 [default=false]; 881767c5feSopenharmony_ci 891767c5feSopenharmony_ci // This field specifies how any carrier code ($CC) together with the first 901767c5feSopenharmony_ci // group ($FG) in the national significant number should be formatted 911767c5feSopenharmony_ci // when formatWithCarrierCode is called, if carrier codes are used for a 921767c5feSopenharmony_ci // certain country. 931767c5feSopenharmony_ci optional string domestic_carrier_code_formatting_rule = 5; 941767c5feSopenharmony_ci} 951767c5feSopenharmony_ci 961767c5feSopenharmony_ci// If you add, remove, or rename fields, or change their semantics, check if you 971767c5feSopenharmony_ci// should change the excludable field sets or the behavior in MetadataFilter. 981767c5feSopenharmony_cimessage PhoneNumberDesc { 991767c5feSopenharmony_ci // The national_number_pattern is the pattern that a valid national 1001767c5feSopenharmony_ci // significant number would match. This specifies information such as its 1011767c5feSopenharmony_ci // total length and leading digits. 1021767c5feSopenharmony_ci optional string national_number_pattern = 2; 1031767c5feSopenharmony_ci 1041767c5feSopenharmony_ci // These represent the lengths a phone number from this region can be. They 1051767c5feSopenharmony_ci // will be sorted from smallest to biggest. Note that these lengths are for 1061767c5feSopenharmony_ci // the full number, without country calling code or national prefix. For 1071767c5feSopenharmony_ci // example, for the Swiss number +41789270000, in local format 0789270000, 1081767c5feSopenharmony_ci // this would be 9. 1091767c5feSopenharmony_ci // This could be used to highlight tokens in a text that may be a phone 1101767c5feSopenharmony_ci // number, or to quickly prune numbers that could not possibly be a phone 1111767c5feSopenharmony_ci // number for this locale. 1121767c5feSopenharmony_ci repeated int32 possible_length = 9; 1131767c5feSopenharmony_ci 1141767c5feSopenharmony_ci // These represent the lengths that only local phone numbers (without an area 1151767c5feSopenharmony_ci // code) from this region can be. They will be sorted from smallest to 1161767c5feSopenharmony_ci // biggest. For example, since the American number 456-1234 may be locally 1171767c5feSopenharmony_ci // diallable, although not diallable from outside the area, 7 could be a 1181767c5feSopenharmony_ci // possible value. 1191767c5feSopenharmony_ci // This could be used to highlight tokens in a text that may be a phone 1201767c5feSopenharmony_ci // number. 1211767c5feSopenharmony_ci // To our knowledge, area codes are usually only relevant for some fixed-line 1221767c5feSopenharmony_ci // and mobile numbers, so this field should only be set for those types of 1231767c5feSopenharmony_ci // numbers (and the general description) - however there are exceptions for 1241767c5feSopenharmony_ci // NANPA countries. 1251767c5feSopenharmony_ci // This data is used to calculate whether a number could be a possible number 1261767c5feSopenharmony_ci // for a particular type. 1271767c5feSopenharmony_ci repeated int32 possible_length_local_only = 10; 1281767c5feSopenharmony_ci 1291767c5feSopenharmony_ci // An example national significant number for the specific type. It should 1301767c5feSopenharmony_ci // not contain any formatting information. 1311767c5feSopenharmony_ci optional string example_number = 6; 1321767c5feSopenharmony_ci} 1331767c5feSopenharmony_ci 1341767c5feSopenharmony_ci// If you add, remove, or rename fields, or change their semantics, check if you 1351767c5feSopenharmony_ci// should change the excludable field sets or the behavior in MetadataFilter. 1361767c5feSopenharmony_cimessage PhoneMetadata { 1371767c5feSopenharmony_ci // The general_desc contains information which is a superset of descriptions 1381767c5feSopenharmony_ci // for all types of phone numbers. If any element is missing in the 1391767c5feSopenharmony_ci // description of a specific type in the XML file, the element will inherit 1401767c5feSopenharmony_ci // from its counterpart in the general_desc. For all types that are generally 1411767c5feSopenharmony_ci // relevant to normal phone numbers, if the whole type is missing in the 1421767c5feSopenharmony_ci // PhoneNumberMetadata XML file, it will not have national number data, and 1431767c5feSopenharmony_ci // the possible lengths will be [-1]. 1441767c5feSopenharmony_ci optional PhoneNumberDesc general_desc = 1; 1451767c5feSopenharmony_ci optional PhoneNumberDesc fixed_line = 2; 1461767c5feSopenharmony_ci optional PhoneNumberDesc mobile = 3; 1471767c5feSopenharmony_ci optional PhoneNumberDesc toll_free = 4; 1481767c5feSopenharmony_ci optional PhoneNumberDesc premium_rate = 5; 1491767c5feSopenharmony_ci optional PhoneNumberDesc shared_cost = 6; 1501767c5feSopenharmony_ci optional PhoneNumberDesc personal_number = 7; 1511767c5feSopenharmony_ci optional PhoneNumberDesc voip = 8; 1521767c5feSopenharmony_ci optional PhoneNumberDesc pager = 21; 1531767c5feSopenharmony_ci optional PhoneNumberDesc uan = 25; 1541767c5feSopenharmony_ci optional PhoneNumberDesc emergency = 27; 1551767c5feSopenharmony_ci optional PhoneNumberDesc voicemail = 28; 1561767c5feSopenharmony_ci optional PhoneNumberDesc short_code = 29; 1571767c5feSopenharmony_ci optional PhoneNumberDesc standard_rate = 30; 1581767c5feSopenharmony_ci optional PhoneNumberDesc carrier_specific = 31; 1591767c5feSopenharmony_ci optional PhoneNumberDesc sms_services = 33; 1601767c5feSopenharmony_ci 1611767c5feSopenharmony_ci // The rules here distinguish the numbers that are only able to be dialled 1621767c5feSopenharmony_ci // nationally. 1631767c5feSopenharmony_ci optional PhoneNumberDesc no_international_dialling = 24; 1641767c5feSopenharmony_ci 1651767c5feSopenharmony_ci // The CLDR 2-letter representation of a country/region, with the exception of 1661767c5feSopenharmony_ci // "country calling codes" used for non-geographical entities, such as 1671767c5feSopenharmony_ci // Universal International Toll Free Number (+800). These are all given the ID 1681767c5feSopenharmony_ci // "001", since this is the numeric region code for the world according to UN 1691767c5feSopenharmony_ci // M.49: http://en.wikipedia.org/wiki/UN_M.49 1701767c5feSopenharmony_ci required string id = 9; 1711767c5feSopenharmony_ci 1721767c5feSopenharmony_ci // The country calling code that one would dial from overseas when trying to 1731767c5feSopenharmony_ci // dial a phone number in this country. For example, this would be "64" for 1741767c5feSopenharmony_ci // New Zealand. 1751767c5feSopenharmony_ci optional int32 country_code = 10; 1761767c5feSopenharmony_ci 1771767c5feSopenharmony_ci // The international_prefix of country A is the number that needs to be 1781767c5feSopenharmony_ci // dialled from country A to another country (country B). This is followed 1791767c5feSopenharmony_ci // by the country code for country B. Note that some countries may have more 1801767c5feSopenharmony_ci // than one international prefix, and for those cases, a regular expression 1811767c5feSopenharmony_ci // matching the international prefixes will be stored in this field. 1821767c5feSopenharmony_ci optional string international_prefix = 11; 1831767c5feSopenharmony_ci 1841767c5feSopenharmony_ci // If the international prefix that we want to use when formatting the number 1851767c5feSopenharmony_ci // for out-of-country dialling contains non-digit symbols, or there is more 1861767c5feSopenharmony_ci // than one international prefix is present, a preferred prefix can be 1871767c5feSopenharmony_ci // specified here for out-of-country formatting purposes. If this field is 1881767c5feSopenharmony_ci // not present, and multiple international prefixes are present, then "+" 1891767c5feSopenharmony_ci // will be used instead. 1901767c5feSopenharmony_ci optional string preferred_international_prefix = 17; 1911767c5feSopenharmony_ci 1921767c5feSopenharmony_ci // The national prefix of country A is the number that needs to be dialled 1931767c5feSopenharmony_ci // before the national significant number when dialling internally. This 1941767c5feSopenharmony_ci // would not be dialled when dialling internationally. For example, in New 1951767c5feSopenharmony_ci // Zealand, the number that would be locally dialled as 09 345 3456 would be 1961767c5feSopenharmony_ci // dialled from overseas as +64 9 345 3456. In this case, 0 is the national 1971767c5feSopenharmony_ci // prefix. 1981767c5feSopenharmony_ci optional string national_prefix = 12; 1991767c5feSopenharmony_ci 2001767c5feSopenharmony_ci // The preferred prefix when specifying an extension in this country. This is 2011767c5feSopenharmony_ci // used for formatting only, and if this is not specified, a suitable default 2021767c5feSopenharmony_ci // should be used instead. For example, if you wanted extensions to be 2031767c5feSopenharmony_ci // formatted in the following way: 2041767c5feSopenharmony_ci // 1 (365) 345 445 ext. 2345 2051767c5feSopenharmony_ci // " ext. " should be the preferred extension prefix. 2061767c5feSopenharmony_ci optional string preferred_extn_prefix = 13; 2071767c5feSopenharmony_ci 2081767c5feSopenharmony_ci // This field is used for cases where the national prefix of a country 2091767c5feSopenharmony_ci // contains a carrier selection code, and is written in the form of a 2101767c5feSopenharmony_ci // regular expression. For example, to dial the number 2222-2222 in 2111767c5feSopenharmony_ci // Fortaleza, Brazil (area code 85) using the long distance carrier Oi 2121767c5feSopenharmony_ci // (selection code 31), one would dial 0 31 85 2222 2222. Assuming the 2131767c5feSopenharmony_ci // only other possible carrier selection code is 32, the field will 2141767c5feSopenharmony_ci // contain "03[12]". 2151767c5feSopenharmony_ci // 2161767c5feSopenharmony_ci // When it is missing from the XML file, this field inherits the value of 2171767c5feSopenharmony_ci // national_prefix, if that is present. 2181767c5feSopenharmony_ci optional string national_prefix_for_parsing = 15; 2191767c5feSopenharmony_ci 2201767c5feSopenharmony_ci // This field is only populated and used under very rare situations. 2211767c5feSopenharmony_ci // For example, mobile numbers in Argentina are written in two completely 2221767c5feSopenharmony_ci // different ways when dialed in-country and out-of-country 2231767c5feSopenharmony_ci // (e.g. 0343 15 555 1212 is exactly the same number as +54 9 343 555 1212). 2241767c5feSopenharmony_ci // This field is used together with national_prefix_for_parsing to transform 2251767c5feSopenharmony_ci // the number into a particular representation for storing in the phonenumber 2261767c5feSopenharmony_ci // proto buffer in those rare cases. 2271767c5feSopenharmony_ci optional string national_prefix_transform_rule = 16; 2281767c5feSopenharmony_ci 2291767c5feSopenharmony_ci // Specifies whether the mobile and fixed-line patterns are the same or not. 2301767c5feSopenharmony_ci // This is used to speed up determining phone number type in countries where 2311767c5feSopenharmony_ci // these two types of phone numbers can never be distinguished. 2321767c5feSopenharmony_ci optional bool same_mobile_and_fixed_line_pattern = 18 [default=false]; 2331767c5feSopenharmony_ci 2341767c5feSopenharmony_ci // Note that the number format here is used for formatting only, not parsing. 2351767c5feSopenharmony_ci // Hence all the varied ways a user *may* write a number need not be recorded 2361767c5feSopenharmony_ci // - just the ideal way we would like to format it for them. When this element 2371767c5feSopenharmony_ci // is absent, the national significant number will be formatted as a whole 2381767c5feSopenharmony_ci // without any formatting applied. 2391767c5feSopenharmony_ci repeated NumberFormat number_format = 19; 2401767c5feSopenharmony_ci 2411767c5feSopenharmony_ci // This field is populated only when the national significant number is 2421767c5feSopenharmony_ci // formatted differently when it forms part of the INTERNATIONAL format 2431767c5feSopenharmony_ci // and NATIONAL format. A case in point is mobile numbers in Argentina: 2441767c5feSopenharmony_ci // The number, which would be written in INTERNATIONAL format as 2451767c5feSopenharmony_ci // +54 9 343 555 1212, will be written as 0343 15 555 1212 for NATIONAL 2461767c5feSopenharmony_ci // format. In this case, the prefix 9 is inserted when dialling from 2471767c5feSopenharmony_ci // overseas, but otherwise the prefix 0 and the carrier selection code 2481767c5feSopenharmony_ci // 15 (inserted after the area code of 343) is used. 2491767c5feSopenharmony_ci // Note: this field is populated by setting a value for <intlFormat> inside 2501767c5feSopenharmony_ci // the <numberFormat> tag in the XML file. If <intlFormat> is not set then it 2511767c5feSopenharmony_ci // defaults to the same value as the <format> tag. 2521767c5feSopenharmony_ci // 2531767c5feSopenharmony_ci // Examples: 2541767c5feSopenharmony_ci // To set the <intlFormat> to a different value than the <format>: 2551767c5feSopenharmony_ci // <numberFormat pattern=....> 2561767c5feSopenharmony_ci // <format>$1 $2 $3</format> 2571767c5feSopenharmony_ci // <intlFormat>$1-$2-$3</intlFormat> 2581767c5feSopenharmony_ci // </numberFormat> 2591767c5feSopenharmony_ci // 2601767c5feSopenharmony_ci // To have a format only used for national formatting, set <intlFormat> to 2611767c5feSopenharmony_ci // "NA": 2621767c5feSopenharmony_ci // <numberFormat pattern=....> 2631767c5feSopenharmony_ci // <format>$1 $2 $3</format> 2641767c5feSopenharmony_ci // <intlFormat>NA</intlFormat> 2651767c5feSopenharmony_ci // </numberFormat> 2661767c5feSopenharmony_ci repeated NumberFormat intl_number_format = 20; 2671767c5feSopenharmony_ci 2681767c5feSopenharmony_ci // This field is set when this country is considered to be the main country 2691767c5feSopenharmony_ci // for a calling code. It may not be set by more than one country with the 2701767c5feSopenharmony_ci // same calling code, and it should not be set by countries with a unique 2711767c5feSopenharmony_ci // calling code. This can be used to indicate that "GB" is the main country 2721767c5feSopenharmony_ci // for the calling code "44" for example, rather than Jersey or the Isle of 2731767c5feSopenharmony_ci // Man. 2741767c5feSopenharmony_ci optional bool main_country_for_code = 22 [default=false]; 2751767c5feSopenharmony_ci 2761767c5feSopenharmony_ci // This field is populated only for countries or regions that share a country 2771767c5feSopenharmony_ci // calling code. If a number matches this pattern, it could belong to this 2781767c5feSopenharmony_ci // region. This is not intended as a replacement for IsValidForRegion since a 2791767c5feSopenharmony_ci // matching prefix is insufficient for a number to be valid. Furthermore, it 2801767c5feSopenharmony_ci // does not contain all the prefixes valid for a region - for example, 800 2811767c5feSopenharmony_ci // numbers are valid for all NANPA countries and are hence not listed here. 2821767c5feSopenharmony_ci // This field should be a regular expression of the expected prefix match. 2831767c5feSopenharmony_ci // It is used merely as a short-cut for working out which region a number 2841767c5feSopenharmony_ci // comes from in the case that there is only one, so leading_digit prefixes 2851767c5feSopenharmony_ci // should not overlap. 2861767c5feSopenharmony_ci optional string leading_digits = 23; 2871767c5feSopenharmony_ci 2881767c5feSopenharmony_ci // This field is set when this country has implemented mobile number 2891767c5feSopenharmony_ci // portability. This means that transferring mobile numbers between carriers 2901767c5feSopenharmony_ci // is allowed. A consequence of this is that phone prefix to carrier mapping 2911767c5feSopenharmony_ci // is less reliable. 2921767c5feSopenharmony_ci optional bool mobile_number_portable_region = 32 [default=false]; 2931767c5feSopenharmony_ci 2941767c5feSopenharmony_ci reserved 26; 2951767c5feSopenharmony_ci reserved "leading_zero_possible"; 2961767c5feSopenharmony_ci} 2971767c5feSopenharmony_ci 2981767c5feSopenharmony_cimessage PhoneMetadataCollection { 2991767c5feSopenharmony_ci repeated PhoneMetadata metadata = 1; 3001767c5feSopenharmony_ci} 301