美文网首页
Android setting中增加Suggested lang

Android setting中增加Suggested lang

作者: 梧叶已秋声 | 来源:发表于2021-01-23 14:37 被阅读0次

首先,给设备增加一个属性persist.language.suggest,具体赋值为frameworks/base/core/res/res/values/locale_config.xml中对应的数据。

//frameworks/base/core/res/res/values/locale_config.xml
<resources>

    <string-array translatable="false" name="supported_locales">
        <item>af-NA</item> <!-- Afrikaans (Namibia) -->
        <item>af-ZA</item> <!-- Afrikaans (South Africa) -->
        <item>agq-CM</item> <!-- Aghem (Cameroon) -->
        <item>ak-GH</item> <!-- Akan (Ghana) -->
        <item>am-ET</item> <!-- Amharic (Ethiopia) -->
        <item>ar-AE</item> <!-- Arabic (United Arab Emirates) -->
        <item>ar-AE-u-nu-latn</item> <!-- Arabic (United Arab Emirates, Western Digits) -->
        <item>ar-BH</item> <!-- Arabic (Bahrain) -->
        <item>ar-BH-u-nu-latn</item> <!-- Arabic (Bahrain, Western Digits) -->
        <item>ar-DJ</item> <!-- Arabic (Djibouti) -->
        <item>ar-DJ-u-nu-latn</item> <!-- Arabic (Djibouti, Western Digits) -->
        <item>ar-DZ</item> <!-- Arabic (Algeria) -->
        <item>ar-DZ-u-nu-arab</item> <!-- Arabic (Algeria, Arabic-Indic Digits) -->
        <item>ar-EG</item> <!-- Arabic (Egypt) -->
        <item>ar-EG-u-nu-latn</item> <!-- Arabic (Egypt, Western Digits) -->
        <item>ar-EH</item> <!-- Arabic (Western Sahara) -->
        <item>ar-EH-u-nu-arab</item> <!-- Arabic (Western Sahara, Arabic-Indic Digits) -->
        <item>ar-ER</item> <!-- Arabic (Eritrea) -->
        <item>ar-ER-u-nu-latn</item> <!-- Arabic (Eritrea, Western Digits) -->
        <item>ar-IL</item> <!-- Arabic (Israel) -->
        <item>ar-IL-u-nu-latn</item> <!-- Arabic (Israel, Western Digits) -->
        <item>ar-IQ</item> <!-- Arabic (Iraq) -->
        <item>ar-IQ-u-nu-latn</item> <!-- Arabic (Iraq, Western Digits) -->
        <item>ar-JO</item> <!-- Arabic (Jordan) -->
        <item>ar-JO-u-nu-latn</item> <!-- Arabic (Jordan, Western Digits) -->
        <item>ar-KM</item> <!-- Arabic (Comoros) -->
        <item>ar-KM-u-nu-latn</item> <!-- Arabic (Comoros, Western Digits) -->
        <item>ar-KW</item> <!-- Arabic (Kuwait) -->
        <item>ar-KW-u-nu-latn</item> <!-- Arabic (Kuwait, Western Digits) -->
        <item>ar-LB</item> <!-- Arabic (Lebanon) -->
        <item>ar-LB-u-nu-latn</item> <!-- Arabic (Lebanon, Western Digits) -->
        <item>ar-LY</item> <!-- Arabic (Libya) -->
        <item>ar-LY-u-nu-arab</item> <!-- Arabic (Libya, Arabic-Indic Digits) -->
        <item>ar-MA</item> <!-- Arabic (Morocco) -->
        <item>ar-MA-u-nu-arab</item> <!-- Arabic (Morocco, Arabic-Indic Digits) -->
        <item>ar-MR</item> <!-- Arabic (Mauritania) -->
        <item>ar-MR-u-nu-latn</item> <!-- Arabic (Mauritania, Western Digits) -->
        <item>ar-OM</item> <!-- Arabic (Oman) -->
        <item>ar-OM-u-nu-latn</item> <!-- Arabic (Oman, Western Digits) -->
        <item>ar-PS</item> <!-- Arabic (Palestine) -->
        <item>ar-PS-u-nu-latn</item> <!-- Arabic (Palestine, Western Digits) -->
        <item>ar-QA</item> <!-- Arabic (Qatar) -->
        <item>ar-QA-u-nu-latn</item> <!-- Arabic (Qatar, Western Digits) -->
        <item>ar-SA</item> <!-- Arabic (Saudi Arabia) -->
        <item>ar-SA-u-nu-latn</item> <!-- Arabic (Saudi Arabia, Western Digits) -->
        <item>ar-SD</item> <!-- Arabic (Sudan) -->
        <item>ar-SD-u-nu-latn</item> <!-- Arabic (Sudan, Western Digits) -->
        <item>ar-SO</item> <!-- Arabic (Somalia) -->
        <item>ar-SO-u-nu-latn</item> <!-- Arabic (Somalia, Western Digits) -->
        <item>ar-SS</item> <!-- Arabic (South Sudan) -->
        <item>ar-SS-u-nu-latn</item> <!-- Arabic (South Sudan, Western Digits) -->
        <item>ar-SY</item> <!-- Arabic (Syria) -->
        <item>ar-SY-u-nu-latn</item> <!-- Arabic (Syria, Western Digits) -->
        <item>ar-TD</item> <!-- Arabic (Chad) -->
        <item>ar-TD-u-nu-latn</item> <!-- Arabic (Chad, Western Digits) -->
        <item>ar-TN</item> <!-- Arabic (Tunisia) -->
        <item>ar-TN-u-nu-arab</item> <!-- Arabic (Tunisia, Arabic-Indic Digits) -->
        <item>ar-XB</item> <!-- Right-to-left pseudolocale -->
        <item>ar-YE</item> <!-- Arabic (Yemen) -->
        <item>ar-YE-u-nu-latn</item> <!-- Arabic (Yemen, Western Digits) -->
        <item>as-IN</item> <!-- Assamese (India) -->
        <item>as-IN-u-nu-latn</item> <!-- Assamese (India, Western Digits) -->
        <item>asa-TZ</item> <!-- Asu (Tanzania) -->
        <item>ast-ES</item> <!-- Asturian (Spain) -->
        <item>az-Cyrl-AZ</item> <!-- Azerbaijani (Cyrillic, Azerbaijan) -->
        <item>az-Latn-AZ</item> <!-- Azerbaijani (Latin, Azerbaijan) -->
        <item>bas-CM</item> <!-- Basaa (Cameroon) -->
        <item>be-BY</item> <!-- Belarusian (Belarus) -->
        <item>bem-ZM</item> <!-- Bemba (Zambia) -->
        <item>bez-TZ</item> <!-- Bena (Tanzania) -->
        <item>bg-BG</item> <!-- Bulgarian (Bulgaria) -->
        <item>bm-ML</item> <!-- Bambara (Mali) -->
        <item>bn-BD</item> <!-- Bangla (Bangladesh) -->
        <item>bn-BD-u-nu-latn</item> <!-- Bangla (Bangladesh, Western Digits) -->
        <item>bn-IN</item> <!-- Bangla (India) -->
        <item>bn-IN-u-nu-latn</item> <!-- Bangla (India, Western Digits) -->
        <item>bo-CN</item> <!-- Tibetan (China) -->
        <item>bo-IN</item> <!-- Tibetan (India) -->
        <item>br-FR</item> <!-- Breton (France) -->
        <item>brx-IN</item> <!-- Bodo (India) -->
        <item>bs-Cyrl-BA</item> <!-- Bosnian (Cyrillic, Bosnia & Herzegovina) -->
        <item>bs-Latn-BA</item> <!-- Bosnian (Latin, Bosnia & Herzegovina) -->
        <item>ca-AD</item> <!-- Catalan (Andorra) -->
        <item>ca-ES</item> <!-- Catalan (Spain) -->
        <item>ca-FR</item> <!-- Catalan (France) -->
        <item>ca-IT</item> <!-- Catalan (Italy) -->
        <item>ce-RU</item> <!-- Chechen (Russia) -->
        <item>cgg-UG</item> <!-- Chiga (Uganda) -->
        <item>chr-US</item> <!-- Cherokee (United States) -->
        <item>cs-CZ</item> <!-- Czech (Czechia) -->
        <item>cy-GB</item> <!-- Welsh (United Kingdom) -->
        <item>da-DK</item> <!-- Danish (Denmark) -->
        <item>da-GL</item> <!-- Danish (Greenland) -->
        <item>dav-KE</item> <!-- Taita (Kenya) -->
        <item>de-AT</item> <!-- German (Austria) -->
        <item>de-BE</item> <!-- German (Belgium) -->
        <item>de-CH</item> <!-- German (Switzerland) -->
        <item>de-DE</item> <!-- German (Germany) -->
        <item>de-IT</item> <!-- German (Italy) -->
        <item>de-LI</item> <!-- German (Liechtenstein) -->
        <item>de-LU</item> <!-- German (Luxembourg) -->
        <item>dje-NE</item> <!-- Zarma (Niger) -->
        <item>dsb-DE</item> <!-- Lower Sorbian (Germany) -->
        <item>dua-CM</item> <!-- Duala (Cameroon) -->
        <item>dyo-SN</item> <!-- Jola-Fonyi (Senegal) -->
        <item>dz-BT</item> <!-- Dzongkha (Bhutan) -->
        <item>ebu-KE</item> <!-- Embu (Kenya) -->
        <item>ee-GH</item> <!-- Ewe (Ghana) -->
        <item>ee-TG</item> <!-- Ewe (Togo) -->
        <item>el-CY</item> <!-- Greek (Cyprus) -->
        <item>el-GR</item> <!-- Greek (Greece) -->
        <item>en-AG</item> <!-- English (Antigua & Barbuda) -->
        <item>en-AI</item> <!-- English (Anguilla) -->
        <item>en-AS</item> <!-- English (American Samoa) -->
        <item>en-AT</item> <!-- English (Austria) -->
        <item>en-AU</item> <!-- English (Australia) -->
        <item>en-BB</item> <!-- English (Barbados) -->
        <item>en-BE</item> <!-- English (Belgium) -->
        <item>en-BI</item> <!-- English (Burundi) -->
        <item>en-BM</item> <!-- English (Bermuda) -->
        <item>en-BS</item> <!-- English (Bahamas) -->
        <item>en-BW</item> <!-- English (Botswana) -->
        <item>en-BZ</item> <!-- English (Belize) -->
        <item>en-CA</item> <!-- English (Canada) -->
        <item>en-CC</item> <!-- English (Cocos (Keeling) Islands) -->
        <item>en-CH</item> <!-- English (Switzerland) -->
        <item>en-CK</item> <!-- English (Cook Islands) -->
        <item>en-CM</item> <!-- English (Cameroon) -->
        <item>en-CX</item> <!-- English (Christmas Island) -->
        <item>en-CY</item> <!-- English (Cyprus) -->
        <item>en-DE</item> <!-- English (Germany) -->
        <item>en-DG</item> <!-- English (Diego Garcia) -->
        <item>en-DK</item> <!-- English (Denmark) -->
        <item>en-DM</item> <!-- English (Dominica) -->
        <item>en-ER</item> <!-- English (Eritrea) -->
        <item>en-FI</item> <!-- English (Finland) -->
        <item>en-FJ</item> <!-- English (Fiji) -->
        <item>en-FK</item> <!-- English (Falkland Islands (Islas Malvinas)) -->
        <item>en-FM</item> <!-- English (Micronesia) -->
        <item>en-GB</item> <!-- English (United Kingdom) -->
        <item>en-GD</item> <!-- English (Grenada) -->
        <item>en-GG</item> <!-- English (Guernsey) -->
        <item>en-GH</item> <!-- English (Ghana) -->
        <item>en-GI</item> <!-- English (Gibraltar) -->
        <item>en-GM</item> <!-- English (Gambia) -->
        <item>en-GU</item> <!-- English (Guam) -->
        <item>en-GY</item> <!-- English (Guyana) -->
        <item>en-HK</item> <!-- English (Hong Kong) -->
        <item>en-IE</item> <!-- English (Ireland) -->
        <item>en-IL</item> <!-- English (Israel) -->
        <item>en-IM</item> <!-- English (Isle of Man) -->
        <item>en-IN</item> <!-- English (India) -->
        <item>en-IO</item> <!-- English (British Indian Ocean Territory) -->
        <item>en-JE</item> <!-- English (Jersey) -->
        <item>en-JM</item> <!-- English (Jamaica) -->
        <item>en-KE</item> <!-- English (Kenya) -->
        <item>en-KI</item> <!-- English (Kiribati) -->
        <item>en-KN</item> <!-- English (St. Kitts & Nevis) -->
        <item>en-KY</item> <!-- English (Cayman Islands) -->
        <item>en-LC</item> <!-- English (St. Lucia) -->
        <item>en-LR</item> <!-- English (Liberia) -->
        <item>en-LS</item> <!-- English (Lesotho) -->
        <item>en-MG</item> <!-- English (Madagascar) -->
        <item>en-MH</item> <!-- English (Marshall Islands) -->
        <item>en-MO</item> <!-- English (Macau) -->
        <item>en-MP</item> <!-- English (Northern Mariana Islands) -->
        <item>en-MS</item> <!-- English (Montserrat) -->
        <item>en-MT</item> <!-- English (Malta) -->
        <item>en-MU</item> <!-- English (Mauritius) -->
        <item>en-MW</item> <!-- English (Malawi) -->
        <item>en-MY</item> <!-- English (Malaysia) -->
        <item>en-NA</item> <!-- English (Namibia) -->
        <item>en-NF</item> <!-- English (Norfolk Island) -->
        <item>en-NG</item> <!-- English (Nigeria) -->
        <item>en-NL</item> <!-- English (Netherlands) -->
        <item>en-NR</item> <!-- English (Nauru) -->
        <item>en-NU</item> <!-- English (Niue) -->
        <item>en-NZ</item> <!-- English (New Zealand) -->
        <item>en-PG</item> <!-- English (Papua New Guinea) -->
        <item>en-PH</item> <!-- English (Philippines) -->
        <item>en-PK</item> <!-- English (Pakistan) -->
        <item>en-PN</item> <!-- English (Pitcairn Islands) -->
        <item>en-PR</item> <!-- English (Puerto Rico) -->
        <item>en-PW</item> <!-- English (Palau) -->
        <item>en-RW</item> <!-- English (Rwanda) -->
        <item>en-SB</item> <!-- English (Solomon Islands) -->
        <item>en-SC</item> <!-- English (Seychelles) -->
        <item>en-SD</item> <!-- English (Sudan) -->
        <item>en-SE</item> <!-- English (Sweden) -->
        <item>en-SG</item> <!-- English (Singapore) -->
        <item>en-SH</item> <!-- English (St. Helena) -->
        <item>en-SI</item> <!-- English (Slovenia) -->
        <item>en-SL</item> <!-- English (Sierra Leone) -->
        <item>en-SS</item> <!-- English (South Sudan) -->
        <item>en-SX</item> <!-- English (Sint Maarten) -->
        <item>en-SZ</item> <!-- English (Swaziland) -->
        <item>en-TC</item> <!-- English (Turks & Caicos Islands) -->
        <item>en-TK</item> <!-- English (Tokelau) -->
        <item>en-TO</item> <!-- English (Tonga) -->
        <item>en-TT</item> <!-- English (Trinidad & Tobago) -->
        <item>en-TV</item> <!-- English (Tuvalu) -->
        <item>en-TZ</item> <!-- English (Tanzania) -->
        <item>en-UG</item> <!-- English (Uganda) -->
        <item>en-UM</item> <!-- English (U.S. Outlying Islands) -->
        <item>en-US</item> <!-- English (United States) -->
        <item>en-VC</item> <!-- English (St. Vincent & Grenadines) -->
        <item>en-VG</item> <!-- English (British Virgin Islands) -->
        <item>en-VI</item> <!-- English (U.S. Virgin Islands) -->
        <item>en-VU</item> <!-- English (Vanuatu) -->
        <item>en-WS</item> <!-- English (Samoa) -->
        <item>en-XA</item> <!-- Left-to-right pseudolocale -->
        <item>en-ZA</item> <!-- English (South Africa) -->
        <item>en-ZM</item> <!-- English (Zambia) -->
        <item>en-ZW</item> <!-- English (Zimbabwe) -->
        <item>es-AR</item> <!-- Spanish (Argentina) -->
        <item>es-BO</item> <!-- Spanish (Bolivia) -->
        <item>es-BR</item> <!-- Spanish (Brazil) -->
        <item>es-BZ</item> <!-- Spanish (Belize) -->
        <item>es-CL</item> <!-- Spanish (Chile) -->
        <item>es-CO</item> <!-- Spanish (Colombia) -->
        <item>es-CR</item> <!-- Spanish (Costa Rica) -->
        <item>es-CU</item> <!-- Spanish (Cuba) -->
        <item>es-DO</item> <!-- Spanish (Dominican Republic) -->
        <item>es-EA</item> <!-- Spanish (Ceuta & Melilla) -->
        <item>es-EC</item> <!-- Spanish (Ecuador) -->
        <item>es-ES</item> <!-- Spanish (Spain) -->
        <item>es-GQ</item> <!-- Spanish (Equatorial Guinea) -->
        <item>es-GT</item> <!-- Spanish (Guatemala) -->
        <item>es-HN</item> <!-- Spanish (Honduras) -->
        <item>es-IC</item> <!-- Spanish (Canary Islands) -->
        <item>es-MX</item> <!-- Spanish (Mexico) -->
        <item>es-NI</item> <!-- Spanish (Nicaragua) -->
        <item>es-PA</item> <!-- Spanish (Panama) -->
        <item>es-PE</item> <!-- Spanish (Peru) -->
        <item>es-PH</item> <!-- Spanish (Philippines) -->
        <item>es-PR</item> <!-- Spanish (Puerto Rico) -->
        <item>es-PY</item> <!-- Spanish (Paraguay) -->
        <item>es-SV</item> <!-- Spanish (El Salvador) -->
        <item>es-US</item> <!-- Spanish (United States) -->
        <item>es-UY</item> <!-- Spanish (Uruguay) -->
        <item>es-VE</item> <!-- Spanish (Venezuela) -->
        <item>et-EE</item> <!-- Estonian (Estonia) -->
        <item>eu-ES</item> <!-- Basque (Spain) -->
        <item>ewo-CM</item> <!-- Ewondo (Cameroon) -->
        <item>fa-AF</item> <!-- Persian (Afghanistan) -->
        <item>fa-AF-u-nu-latn</item> <!-- Persian (Afghanistan, Western Digits) -->
        <item>fa-IR</item> <!-- Persian (Iran) -->
        <item>fa-IR-u-nu-latn</item> <!-- Persian (Iran, Western Digits) -->
        <item>ff-CM</item> <!-- Fulah (Cameroon) -->
        <item>ff-GN</item> <!-- Fulah (Guinea) -->
        <item>ff-MR</item> <!-- Fulah (Mauritania) -->
        <item>ff-SN</item> <!-- Fulah (Senegal) -->
        <item>fi-FI</item> <!-- Finnish (Finland) -->
        <item>fil-PH</item> <!-- Filipino (Philippines) -->
        <item>fo-DK</item> <!-- Faroese (Denmark) -->
        <item>fo-FO</item> <!-- Faroese (Faroe Islands) -->
        <item>fr-BE</item> <!-- French (Belgium) -->
        <item>fr-BF</item> <!-- French (Burkina Faso) -->
        <item>fr-BI</item> <!-- French (Burundi) -->
        <item>fr-BJ</item> <!-- French (Benin) -->
        <item>fr-BL</item> <!-- French (St. Barthélemy) -->
        <item>fr-CA</item> <!-- French (Canada) -->
        <item>fr-CD</item> <!-- French (Congo - Kinshasa) -->
        <item>fr-CF</item> <!-- French (Central African Republic) -->
        <item>fr-CG</item> <!-- French (Congo - Brazzaville) -->
        <item>fr-CH</item> <!-- French (Switzerland) -->
        <item>fr-CI</item> <!-- French (Côte d’Ivoire) -->
        <item>fr-CM</item> <!-- French (Cameroon) -->
        <item>fr-DJ</item> <!-- French (Djibouti) -->
        <item>fr-DZ</item> <!-- French (Algeria) -->
        <item>fr-FR</item> <!-- French (France) -->
        <item>fr-GA</item> <!-- French (Gabon) -->
        <item>fr-GF</item> <!-- French (French Guiana) -->
        <item>fr-GN</item> <!-- French (Guinea) -->
        <item>fr-GP</item> <!-- French (Guadeloupe) -->
        <item>fr-GQ</item> <!-- French (Equatorial Guinea) -->
        <item>fr-HT</item> <!-- French (Haiti) -->
        <item>fr-KM</item> <!-- French (Comoros) -->
        <item>fr-LU</item> <!-- French (Luxembourg) -->
        <item>fr-MA</item> <!-- French (Morocco) -->
        <item>fr-MC</item> <!-- French (Monaco) -->
        <item>fr-MF</item> <!-- French (St. Martin) -->
        <item>fr-MG</item> <!-- French (Madagascar) -->
        <item>fr-ML</item> <!-- French (Mali) -->
        <item>fr-MQ</item> <!-- French (Martinique) -->
        <item>fr-MR</item> <!-- French (Mauritania) -->
        <item>fr-MU</item> <!-- French (Mauritius) -->
        <item>fr-NC</item> <!-- French (New Caledonia) -->
        <item>fr-NE</item> <!-- French (Niger) -->
        <item>fr-PF</item> <!-- French (French Polynesia) -->
        <item>fr-PM</item> <!-- French (St. Pierre & Miquelon) -->
        <item>fr-RE</item> <!-- French (Réunion) -->
        <item>fr-RW</item> <!-- French (Rwanda) -->
        <item>fr-SC</item> <!-- French (Seychelles) -->
        <item>fr-SN</item> <!-- French (Senegal) -->
        <item>fr-SY</item> <!-- French (Syria) -->
        <item>fr-TD</item> <!-- French (Chad) -->
        <item>fr-TG</item> <!-- French (Togo) -->
        <item>fr-TN</item> <!-- French (Tunisia) -->
        <item>fr-VU</item> <!-- French (Vanuatu) -->
        <item>fr-WF</item> <!-- French (Wallis & Futuna) -->
        <item>fr-YT</item> <!-- French (Mayotte) -->
        <item>fur-IT</item> <!-- Friulian (Italy) -->
        <item>fy-NL</item> <!-- Western Frisian (Netherlands) -->
        <item>ga-IE</item> <!-- Irish (Ireland) -->
        <item>gd-GB</item> <!-- Scottish Gaelic (United Kingdom) -->
        <item>gl-ES</item> <!-- Galician (Spain) -->
        <item>gsw-CH</item> <!-- Swiss German (Switzerland) -->
        <item>gsw-FR</item> <!-- Swiss German (France) -->
        <item>gsw-LI</item> <!-- Swiss German (Liechtenstein) -->
        <item>gu-IN</item> <!-- Gujarati (India) -->
        <item>guz-KE</item> <!-- Gusii (Kenya) -->
        <item>gv-IM</item> <!-- Manx (Isle of Man) -->
        <item>ha-GH</item> <!-- Hausa (Ghana) -->
        <item>ha-NE</item> <!-- Hausa (Niger) -->
        <item>ha-NG</item> <!-- Hausa (Nigeria) -->
        <item>haw-US</item> <!-- Hawaiian (United States) -->
        <item>hi-IN</item> <!-- Hindi (India) -->
        <item>hr-BA</item> <!-- Croatian (Bosnia & Herzegovina) -->
        <item>hr-HR</item> <!-- Croatian (Croatia) -->
        <item>hsb-DE</item> <!-- Upper Sorbian (Germany) -->
        <item>hu-HU</item> <!-- Hungarian (Hungary) -->
        <item>hy-AM</item> <!-- Armenian (Armenia) -->
        <item>ig-NG</item> <!-- Igbo (Nigeria) -->
        <item>ii-CN</item> <!-- Sichuan Yi (China) -->
        <item>in-ID</item> <!-- Indonesian (Indonesia) -->
        <item>is-IS</item> <!-- Icelandic (Iceland) -->
        <item>it-CH</item> <!-- Italian (Switzerland) -->
        <item>it-IT</item> <!-- Italian (Italy) -->
        <item>it-SM</item> <!-- Italian (San Marino) -->
        <item>iw-IL</item> <!-- Hebrew (Israel) -->
        <item>ja-JP</item> <!-- Japanese (Japan) -->
        <item>jgo-CM</item> <!-- Ngomba (Cameroon) -->
        <item>jmc-TZ</item> <!-- Machame (Tanzania) -->
        <item>ka-GE</item> <!-- Georgian (Georgia) -->
        <item>kab-DZ</item> <!-- Kabyle (Algeria) -->
        <item>kam-KE</item> <!-- Kamba (Kenya) -->
        <item>kde-TZ</item> <!-- Makonde (Tanzania) -->
        <item>kea-CV</item> <!-- Kabuverdianu (Cape Verde) -->
        <item>khq-ML</item> <!-- Koyra Chiini (Mali) -->
        <item>ki-KE</item> <!-- Kikuyu (Kenya) -->
        <item>kk-KZ</item> <!-- Kazakh (Kazakhstan) -->
        <item>kkj-CM</item> <!-- Kako (Cameroon) -->
        <item>kl-GL</item> <!-- Kalaallisut (Greenland) -->
        <item>kln-KE</item> <!-- Kalenjin (Kenya) -->
        <item>km-KH</item> <!-- Khmer (Cambodia) -->
        <item>kn-IN</item> <!-- Kannada (India) -->
        <item>ko-KP</item> <!-- Korean (North Korea) -->
        <item>ko-KR</item> <!-- Korean (South Korea) -->
        <item>kok-IN</item> <!-- Konkani (India) -->
        <item>ksb-TZ</item> <!-- Shambala (Tanzania) -->
        <item>ksf-CM</item> <!-- Bafia (Cameroon) -->
        <item>ksh-DE</item> <!-- Colognian (Germany) -->
        <item>kw-GB</item> <!-- Cornish (United Kingdom) -->
        <item>ky-KG</item> <!-- Kyrgyz (Kyrgyzstan) -->
        <item>lag-TZ</item> <!-- Langi (Tanzania) -->
        <item>lb-LU</item> <!-- Luxembourgish (Luxembourg) -->
        <item>lg-UG</item> <!-- Ganda (Uganda) -->
        <item>lkt-US</item> <!-- Lakota (United States) -->
        <item>ln-AO</item> <!-- Lingala (Angola) -->
        <item>ln-CD</item> <!-- Lingala (Congo - Kinshasa) -->
        <item>ln-CF</item> <!-- Lingala (Central African Republic) -->
        <item>ln-CG</item> <!-- Lingala (Congo - Brazzaville) -->
        <item>lo-LA</item> <!-- Lao (Laos) -->
        <item>lt-LT</item> <!-- Lithuanian (Lithuania) -->
        <item>lu-CD</item> <!-- Luba-Katanga (Congo - Kinshasa) -->
        <item>luo-KE</item> <!-- Luo (Kenya) -->
        <item>luy-KE</item> <!-- Luyia (Kenya) -->
        <item>lv-LV</item> <!-- Latvian (Latvia) -->
        <item>mas-KE</item> <!-- Masai (Kenya) -->
        <item>mas-TZ</item> <!-- Masai (Tanzania) -->
        <item>mer-KE</item> <!-- Meru (Kenya) -->
        <item>mfe-MU</item> <!-- Morisyen (Mauritius) -->
        <item>mg-MG</item> <!-- Malagasy (Madagascar) -->
        <item>mgh-MZ</item> <!-- Makhuwa-Meetto (Mozambique) -->
        <item>mgo-CM</item> <!-- Metaʼ (Cameroon) -->
        <item>mk-MK</item> <!-- Macedonian (Macedonia (FYROM)) -->
        <item>ml-IN</item> <!-- Malayalam (India) -->
        <item>mn-MN</item> <!-- Mongolian (Mongolia) -->
        <item>mr-IN</item> <!-- Marathi (India) -->
        <item>ms-BN</item> <!-- Malay (Brunei) -->
        <item>ms-MY</item> <!-- Malay (Malaysia) -->
        <item>ms-SG</item> <!-- Malay (Singapore) -->
        <item>mt-MT</item> <!-- Maltese (Malta) -->
        <item>my-MM</item> <!-- Burmese (Myanmar (Burma)) -->
        <item>my-MM-u-nu-latn</item> <!-- Burmese (Myanmar (Burma), Western Digits) -->
        <item>mzn-IR</item> <!-- Mazanderani (Iran) -->
        <item>naq-NA</item> <!-- Nama (Namibia) -->
        <item>nb-NO</item> <!-- Norwegian Bokmål (Norway) -->
        <item>nb-SJ</item> <!-- Norwegian Bokmål (Svalbard & Jan Mayen) -->
        <item>nd-ZW</item> <!-- North Ndebele (Zimbabwe) -->
        <item>ne-IN</item> <!-- Nepali (India) -->
        <item>ne-NP</item> <!-- Nepali (Nepal) -->
        <item>nl-AW</item> <!-- Dutch (Aruba) -->
        <item>nl-BE</item> <!-- Dutch (Belgium) -->
        <item>nl-BQ</item> <!-- Dutch (Caribbean Netherlands) -->
        <item>nl-CW</item> <!-- Dutch (Curaçao) -->
        <item>nl-NL</item> <!-- Dutch (Netherlands) -->
        <item>nl-SR</item> <!-- Dutch (Suriname) -->
        <item>nl-SX</item> <!-- Dutch (Sint Maarten) -->
        <item>nn-NO</item> <!-- Norwegian Nynorsk (Norway) -->
        <item>nnh-CM</item> <!-- Ngiemboon (Cameroon) -->
        <item>nus-SS</item> <!-- Nuer (South Sudan) -->
        <item>nyn-UG</item> <!-- Nyankole (Uganda) -->
        <item>om-ET</item> <!-- Oromo (Ethiopia) -->
        <item>om-KE</item> <!-- Oromo (Kenya) -->
        <item>or-IN</item> <!-- Odia (India) -->
        <item>os-GE</item> <!-- Ossetic (Georgia) -->
        <item>os-RU</item> <!-- Ossetic (Russia) -->
        <item>pa-Arab-PK</item> <!-- Punjabi (Arabic, Pakistan) -->
        <item>pa-Guru-IN</item> <!-- Punjabi (Gurmukhi, India) -->
        <item>pl-PL</item> <!-- Polish (Poland) -->
        <item>ps-AF</item> <!-- Pashto (Afghanistan) -->
        <item>pt-AO</item> <!-- Portuguese (Angola) -->
        <item>pt-BR</item> <!-- Portuguese (Brazil) -->
        <item>pt-CV</item> <!-- Portuguese (Cape Verde) -->
        <item>pt-GW</item> <!-- Portuguese (Guinea-Bissau) -->
        <item>pt-MO</item> <!-- Portuguese (Macau) -->
        <item>pt-MZ</item> <!-- Portuguese (Mozambique) -->
        <item>pt-PT</item> <!-- Portuguese (Portugal) -->
        <item>pt-ST</item> <!-- Portuguese (São Tomé & Príncipe) -->
        <item>pt-TL</item> <!-- Portuguese (Timor-Leste) -->
        <item>qu-BO</item> <!-- Quechua (Bolivia) -->
        <item>qu-EC</item> <!-- Quechua (Ecuador) -->
        <item>qu-PE</item> <!-- Quechua (Peru) -->
        <item>rm-CH</item> <!-- Romansh (Switzerland) -->
        <item>rn-BI</item> <!-- Rundi (Burundi) -->
        <item>ro-MD</item> <!-- Romanian (Moldova) -->
        <item>ro-RO</item> <!-- Romanian (Romania) -->
        <item>rof-TZ</item> <!-- Rombo (Tanzania) -->
        <item>ru-BY</item> <!-- Russian (Belarus) -->
        <item>ru-KG</item> <!-- Russian (Kyrgyzstan) -->
        <item>ru-KZ</item> <!-- Russian (Kazakhstan) -->
        <item>ru-MD</item> <!-- Russian (Moldova) -->
        <item>ru-RU</item> <!-- Russian (Russia) -->
        <item>ru-UA</item> <!-- Russian (Ukraine) -->
        <item>rw-RW</item> <!-- Kinyarwanda (Rwanda) -->
        <item>rwk-TZ</item> <!-- Rwa (Tanzania) -->
        <item>sah-RU</item> <!-- Sakha (Russia) -->
        <item>saq-KE</item> <!-- Samburu (Kenya) -->
        <item>sbp-TZ</item> <!-- Sangu (Tanzania) -->
        <item>se-FI</item> <!-- Northern Sami (Finland) -->
        <item>se-NO</item> <!-- Northern Sami (Norway) -->
        <item>se-SE</item> <!-- Northern Sami (Sweden) -->
        <item>seh-MZ</item> <!-- Sena (Mozambique) -->
        <item>ses-ML</item> <!-- Koyraboro Senni (Mali) -->
        <item>sg-CF</item> <!-- Sango (Central African Republic) -->
        <item>si-LK</item> <!-- Sinhala (Sri Lanka) -->
        <item>sk-SK</item> <!-- Slovak (Slovakia) -->
        <item>sl-SI</item> <!-- Slovenian (Slovenia) -->
        <item>smn-FI</item> <!-- Inari Sami (Finland) -->
        <item>sn-ZW</item> <!-- Shona (Zimbabwe) -->
        <item>so-DJ</item> <!-- Somali (Djibouti) -->
        <item>so-ET</item> <!-- Somali (Ethiopia) -->
        <item>so-KE</item> <!-- Somali (Kenya) -->
        <item>so-SO</item> <!-- Somali (Somalia) -->
        <item>sq-AL</item> <!-- Albanian (Albania) -->
        <item>sq-MK</item> <!-- Albanian (Macedonia (FYROM)) -->
        <item>sq-XK</item> <!-- Albanian (Kosovo) -->
        <item>sr-Cyrl-BA</item> <!-- Serbian (Cyrillic, Bosnia & Herzegovina) -->
        <item>sr-Cyrl-ME</item> <!-- Serbian (Cyrillic, Montenegro) -->
        <item>sr-Cyrl-RS</item> <!-- Serbian (Cyrillic, Serbia) -->
        <item>sr-Cyrl-XK</item> <!-- Serbian (Cyrillic, Kosovo) -->
        <item>sr-Latn-BA</item> <!-- Serbian (Latin, Bosnia & Herzegovina) -->
        <item>sr-Latn-ME</item> <!-- Serbian (Latin, Montenegro) -->
        <item>sr-Latn-RS</item> <!-- Serbian (Latin, Serbia) -->
        <item>sr-Latn-XK</item> <!-- Serbian (Latin, Kosovo) -->
        <item>sv-AX</item> <!-- Swedish (Åland Islands) -->
        <item>sv-FI</item> <!-- Swedish (Finland) -->
        <item>sv-SE</item> <!-- Swedish (Sweden) -->
        <item>sw-CD</item> <!-- Swahili (Congo - Kinshasa) -->
        <item>sw-KE</item> <!-- Swahili (Kenya) -->
        <item>sw-TZ</item> <!-- Swahili (Tanzania) -->
        <item>sw-UG</item> <!-- Swahili (Uganda) -->
        <item>ta-IN</item> <!-- Tamil (India) -->
        <item>ta-LK</item> <!-- Tamil (Sri Lanka) -->
        <item>ta-MY</item> <!-- Tamil (Malaysia) -->
        <item>ta-SG</item> <!-- Tamil (Singapore) -->
        <item>te-IN</item> <!-- Telugu (India) -->
        <item>teo-KE</item> <!-- Teso (Kenya) -->
        <item>teo-UG</item> <!-- Teso (Uganda) -->
        <item>th-TH</item> <!-- Thai (Thailand) -->
        <item>to-TO</item> <!-- Tongan (Tonga) -->
        <item>tr-CY</item> <!-- Turkish (Cyprus) -->
        <item>tr-TR</item> <!-- Turkish (Turkey) -->
        <item>twq-NE</item> <!-- Tasawaq (Niger) -->
        <item>tzm-MA</item> <!-- Central Atlas Tamazight (Morocco) -->
        <item>ug-CN</item> <!-- Uyghur (China) -->
        <item>uk-UA</item> <!-- Ukrainian (Ukraine) -->
        <item>ur-IN</item> <!-- Urdu (India) -->
        <item>ur-IN-u-nu-latn</item> <!-- Urdu (India, Western Digits) -->
        <item>ur-PK</item> <!-- Urdu (Pakistan) -->
        <item>ur-PK-u-nu-arabext</item> <!-- Urdu (Pakistan, Extended Arabic-Indic Digits) -->
        <item>uz-Arab-AF</item> <!-- Uzbek (Arabic, Afghanistan) -->
        <item>uz-Cyrl-UZ</item> <!-- Uzbek (Cyrillic, Uzbekistan) -->
        <item>uz-Latn-UZ</item> <!-- Uzbek (Latin, Uzbekistan) -->
        <item>vi-VN</item> <!-- Vietnamese (Vietnam) -->
        <item>vun-TZ</item> <!-- Vunjo (Tanzania) -->
        <item>wae-CH</item> <!-- Walser (Switzerland) -->
        <item>xog-UG</item> <!-- Soga (Uganda) -->
        <item>yav-CM</item> <!-- Yangben (Cameroon) -->
        <item>yo-BJ</item> <!-- Yoruba (Benin) -->
        <item>yo-NG</item> <!-- Yoruba (Nigeria) -->
        <item>yue-Hans-CN</item> <!-- Cantonese (Simplified, China) -->
        <item>yue-Hant-HK</item> <!-- Cantonese (Traditional, Hong Kong) -->
        <item>zgh-MA</item> <!-- Standard Moroccan Tamazight (Morocco) -->
        <item>zh-Hans-CN</item> <!-- Chinese (Simplified, China) -->
        <item>zh-Hans-HK</item> <!-- Chinese (Simplified, Hong Kong) -->
        <item>zh-Hans-MO</item> <!-- Chinese (Simplified, Macau) -->
        <item>zh-Hans-SG</item> <!-- Chinese (Simplified, Singapore) -->
        <item>zh-Hant-HK</item> <!-- Chinese (Traditional, Hong Kong) -->
        <item>zh-Hant-MO</item> <!-- Chinese (Traditional, Macau) -->
        <item>zh-Hant-TW</item> <!-- Chinese (Traditional, Taiwan) -->
        <item>zu-ZA</item> <!-- Zulu (South Africa) -->
    </string-array>

</resources>

例如en-US,前面en是语言代码(使用的是ISO 639-1),后面US是地区代码(使用的是ISO 3166-1)。因为英语虽然是一种语言,但是在不同的地区,语言实际有一定的差异(例如英国的英语,澳大利亚的英语)。
找到所需添加的语言以及所对应的地区,加到buildinfo.sh中。

//build/make/tools/buildinfo.sh
.......
echo "persist.language.suggest=ca-ES,en-US,es-ES,eu-ES,gl-ES,fr-FR,it-IT,pt-PT"
echo "# end build properties"

修改LocaleStore中的添加Suggested languages部分。

//frameworks/base/core/java/com/android/internal/app/LocaleStore.java
public class LocaleStore {
   ............
    public static void fillCache(Context context) {
        ............
        for (LocaleInfo li : sLocaleCache.values()) {
            //li.setTranslated(localizedLocales.contains(li.getLangScriptKey()));
            if(isSuggestedLocalesForCustom(li)){
                li.setTranslated(true);
                li.mSuggestionFlags |= LocaleInfo.SUGGESTION_TYPE_SIM;
            }else{
                li.setTranslated(localizedLocales.contains(li.getLangScriptKey()));
            }
        }
        addSuggestedLocalesForRegion(Locale.getDefault());

        sFullyInitialized = true;
    }

    private static boolean isSuggestedLocalesForCustom(LocaleInfo li){
        String suggestLocalStr = android.os.SystemProperties.get("persist.language.suggest");
        if(android.text.TextUtils.isEmpty(suggestLocalStr)){
            return false;
        }
        Locale locale = li.getLocale();
        String langOrContry = android.text.TextUtils.isEmpty(locale.getScript())
                ? (locale.getLanguage() + "-" + locale.getCountry())
                : (locale.getLanguage() + "-" + locale.getScript() + "-" + locale.getCountry());

        String[] suggestLocalArg = suggestLocalStr.split(",");
        for(String suggestLocal : suggestLocalArg){
            if("".equals(suggestLocal.trim())){
                continue;
            }
            if(suggestLocal.equals(langOrContry)){
                return true;
            }
        }
        return false;
    }


}

参考链接:
Android定制语言
Android7.0 & 8.0 Language Settings 定制

相关文章

网友评论

      本文标题:Android setting中增加Suggested lang

      本文链接:https://www.haomeiwen.com/subject/bofuzktx.html