1 // Copyright (C) 2014 Google Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef I18N_ADDRESSINPUT_LANGUAGE_H_ 16 #define I18N_ADDRESSINPUT_LANGUAGE_H_ 17 18 #include <string> 19 20 namespace i18n { 21 namespace addressinput { 22 23 class Rule; 24 25 // Helper for working with a BCP 47 language tag. 26 // http://tools.ietf.org/html/bcp47 27 struct Language { 28 explicit Language(const std::string& language_tag); 29 ~Language(); 30 31 // The language tag (with '_' replaced with '-'), for example "zh-Latn-CN". 32 std::string tag; 33 34 // The base language, for example "zh". Always lowercase. 35 std::string base; 36 37 // True if the language tag explicitly has a Latin script. For example, this 38 // is true for "zh-Latn", but false for "zh". Only the second and third subtag 39 // positions are supported for script. 40 bool has_latin_script; 41 }; 42 43 Language ChooseBestAddressLanguage(const Rule& address_region_rule, 44 const Language& ui_language); 45 46 } // namespace addressinput 47 } // namespace i18n 48 49 #endif // I18N_ADDRESSINPUT_LANGUAGE_H_ 50