LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/i18nlangtag/source/isolang - isolang.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 148 198 74.7 %
Date: 2013-07-09 Functions: 11 12 91.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <rtl/ustring.hxx>
      21             : #include <rtl/string.hxx>
      22             : #include <rtl/ustrbuf.hxx>
      23             : #include <rtl/strbuf.hxx>
      24             : 
      25             : #include "i18nlangtag/mslangid.hxx"
      26             : 
      27             : // =======================================================================
      28             : 
      29             : struct IsoLangEngEntry
      30             : {
      31             :     LanguageType        mnLang;
      32             :     sal_Char            maCountry[3];
      33             : };
      34             : 
      35             : struct IsoLangNoneStdEntry
      36             : {
      37             :     LanguageType        mnLang;
      38             :     sal_Char            maLangStr[4];
      39             :     sal_Char            maCountry[9];
      40             : };
      41             : 
      42             : struct IsoLangOtherEntry
      43             : {
      44             :     LanguageType        mnLang;
      45             :     const sal_Char*     mpLangStr;
      46             : };
      47             : 
      48             : // -----------------------------------------------------------------------
      49             : 
      50             : // Entries for languages are lower case, for countries upper case, as
      51             : // recommended by rfc4646 (obsoletes rfc3066 (obsoletes rfc1766)).
      52             : // convertIsoNamesToLanguage() is case insensitive
      53             : //
      54             : // Sort order: Most used first.
      55             : //
      56             : // The default entry for a LangID <-> ISO mapping has to be first. For
      57             : // conversion of legacy mappings one LangID can map to multiple ISO codes, and
      58             : // one ISO code combination can map to multiple LangIDs. For compatibility with
      59             : // already existing calls it can also be a sequence as follows:
      60             : 
      61             : // LANGUAGE_ENGLISH,    "en", ""
      62             : // LANGUAGE_ENGLISH_US, "en", "US"
      63             : 
      64             : // Here, in a convertIsoNamesToLanguage() call "en-US" is converted to
      65             : // LANGUAGE_ENGLISH_US and "en" is converted to LANGUAGE_ENGLISH. A call with
      66             : // "en-ZZ" (not in table) would result in LANGUAGE_ENGLISH because the first
      67             : // entry matching the language and not having a country is returned, regardless
      68             : // of whether being sorted before or after other entries of the same language
      69             : // with some country. To obtain a _locale_ (not language only) in the order
      70             : // given, convertLocaleToLanguageWithFallback() must be called.
      71             : 
      72             : // If the sequence instead was
      73             : 
      74             : // LANGUAGE_ENGLISH_US, "en", "US"
      75             : // LANGUAGE_ENGLISH,    "en", ""
      76             : 
      77             : // in a convertIsoNamesToLanguage() call "en-US" is still converted to
      78             : // LANGUAGE_ENGLISH_US, but "en" is _also_ converted to LANGUAGE_ENGLISH_US
      79             : // because no country was passed and it is the first entry to match the
      80             : // language, see code. A call with "en-ZZ" (not in table) would still result in
      81             : // LANGUAGE_ENGLISH.
      82             : 
      83             : /* erAck: 2007-07-05T20:01+0200  TODO: The entire suite's "primary language
      84             :  * only" usage and locale fall back should be cleaned up and made consistent. I
      85             :  * strongly doubt that most callers exactly expect the behavior described.
      86             :  * Currently these primary LangIDs are used literally in OOo code:
      87             :  * LANGUAGE_ENGLISH LANGUAGE_CHINESE LANGUAGE_MALAY
      88             :  * LANGUAGE_AZERI LANGUAGE_URDU LANGUAGE_KASHMIRI
      89             :  */
      90             : 
      91             : static MsLangId::IsoLangEntry const aImplIsoLangEntries[] =
      92             : {
      93             :     // MS-LANGID codes               ISO639-1/2/3 ISO3166
      94             :     { LANGUAGE_ENGLISH,                     "en", ""   },
      95             :     { LANGUAGE_ENGLISH_US,                  "en", "US" },
      96             :     { LANGUAGE_ENGLISH_UK,                  "en", "GB" },
      97             :     { LANGUAGE_ENGLISH_AUS,                 "en", "AU" },
      98             :     { LANGUAGE_ENGLISH_CAN,                 "en", "CA" },
      99             :     { LANGUAGE_FRENCH,                      "fr", "FR" },
     100             :     { LANGUAGE_FRENCH,                      "fr", ""   },
     101             :     { LANGUAGE_GERMAN,                      "de", "DE" },
     102             :     { LANGUAGE_ITALIAN,                     "it", "IT" },
     103             :     { LANGUAGE_DUTCH,                       "nl", "NL" },
     104             :     { LANGUAGE_SPANISH_MODERN,              "es", "ES" },
     105             :     { LANGUAGE_SPANISH_DATED,               "es", "ES" },
     106             :     { LANGUAGE_PORTUGUESE,                  "pt", "PT" },
     107             :     { LANGUAGE_PORTUGUESE_BRAZILIAN,        "pt", "BR" },
     108             :     { LANGUAGE_DANISH,                      "da", "DK" },
     109             :     { LANGUAGE_GREEK,                       "el", "GR" },
     110             :     { LANGUAGE_CHINESE,                     "zh", ""   },
     111             :     { LANGUAGE_CHINESE_SIMPLIFIED,          "zh", "CN" },
     112             :     { LANGUAGE_CHINESE_TRADITIONAL,         "zh", "TW" },
     113             :     { LANGUAGE_CHINESE_HONGKONG,            "zh", "HK" },
     114             :     { LANGUAGE_CHINESE_SINGAPORE,           "zh", "SG" },
     115             :     { LANGUAGE_CHINESE_MACAU,               "zh", "MO" },
     116             :     { LANGUAGE_ENGLISH_HONG_KONG_SAR,       "en", "HK" },
     117             :     { LANGUAGE_JAPANESE,                    "ja", "JP" },
     118             :     { LANGUAGE_KOREAN,                      "ko", "KR" },
     119             :     { LANGUAGE_KOREAN_JOHAB,                "ko", "KR" },
     120             :     { LANGUAGE_USER_KOREAN_NORTH,           "ko", "KP" },
     121             :     { LANGUAGE_SWEDISH,                     "sv", "SE" },
     122             :     { LANGUAGE_SWEDISH_FINLAND,             "sv", "FI" },
     123             :     { LANGUAGE_FINNISH,                     "fi", "FI" },
     124             :     { LANGUAGE_RUSSIAN,                     "ru", "RU" },
     125             :     { LANGUAGE_TATAR,                       "tt", "RU" },
     126             :     { LANGUAGE_ENGLISH_NZ,                  "en", "NZ" },
     127             :     { LANGUAGE_ENGLISH_EIRE,                "en", "IE" },
     128             :     { LANGUAGE_DUTCH_BELGIAN,               "nl", "BE" },
     129             :     { LANGUAGE_FRENCH_BELGIAN,              "fr", "BE" },
     130             :     { LANGUAGE_FRENCH_CANADIAN,             "fr", "CA" },
     131             :     { LANGUAGE_FRENCH_SWISS,                "fr", "CH" },
     132             :     { LANGUAGE_GERMAN_SWISS,                "de", "CH" },
     133             :     { LANGUAGE_GERMAN_AUSTRIAN,             "de", "AT" },
     134             :     { LANGUAGE_ITALIAN_SWISS,               "it", "CH" },
     135             :     { LANGUAGE_ALBANIAN,                    "sq", "AL" },
     136             :     { LANGUAGE_ARABIC_SAUDI_ARABIA,         "ar", "SA" },
     137             :     { LANGUAGE_ARABIC_EGYPT,                "ar", "EG" },
     138             :     { LANGUAGE_ARABIC_UAE,                  "ar", "AE" },
     139             :     { LANGUAGE_ARABIC_IRAQ,                 "ar", "IQ" },
     140             :     { LANGUAGE_ARABIC_LIBYA,                "ar", "LY" },
     141             :     { LANGUAGE_ARABIC_ALGERIA,              "ar", "DZ" },
     142             :     { LANGUAGE_ARABIC_MOROCCO,              "ar", "MA" },
     143             :     { LANGUAGE_ARABIC_TUNISIA,              "ar", "TN" },
     144             :     { LANGUAGE_ARABIC_OMAN,                 "ar", "OM" },
     145             :     { LANGUAGE_ARABIC_YEMEN,                "ar", "YE" },
     146             :     { LANGUAGE_ARABIC_SYRIA,                "ar", "SY" },
     147             :     { LANGUAGE_ARABIC_JORDAN,               "ar", "JO" },
     148             :     { LANGUAGE_ARABIC_LEBANON,              "ar", "LB" },
     149             :     { LANGUAGE_ARABIC_KUWAIT,               "ar", "KW" },
     150             :     { LANGUAGE_ARABIC_BAHRAIN,              "ar", "BH" },
     151             :     { LANGUAGE_ARABIC_QATAR,                "ar", "QA" },
     152             :     { LANGUAGE_USER_ARABIC_CHAD,            "ar", "TD" },
     153             :     { LANGUAGE_USER_ARABIC_COMOROS,         "ar", "KM" },
     154             :     { LANGUAGE_USER_ARABIC_DJIBOUTI,        "ar", "DJ" },
     155             :     { LANGUAGE_USER_ARABIC_ERITREA,         "ar", "ER" },
     156             :     { LANGUAGE_USER_ARABIC_ISRAEL,          "ar", "IL" },
     157             :     { LANGUAGE_USER_ARABIC_MAURITANIA,      "ar", "MR" },
     158             :     { LANGUAGE_USER_ARABIC_PALESTINE,       "ar", "PS" },
     159             :     { LANGUAGE_USER_ARABIC_SOMALIA,         "ar", "SO" },
     160             :     { LANGUAGE_USER_ARABIC_SUDAN,           "ar", "SD" },
     161             :     { LANGUAGE_ARABIC_PRIMARY_ONLY,         "ar", ""   },
     162             :     { LANGUAGE_BASQUE,                      "eu", ""   },
     163             :     { LANGUAGE_BULGARIAN,                   "bg", "BG" },
     164             :     { LANGUAGE_CZECH,                       "cs", "CZ" },
     165             :     { LANGUAGE_CZECH,                       "cz", ""   },
     166             :     { LANGUAGE_ENGLISH_JAMAICA,             "en", "JM" },
     167             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "en", "BS" },   // not 100%, because AG is Bahamas
     168             :     { LANGUAGE_ENGLISH_BELIZE,              "en", "BZ" },
     169             :     { LANGUAGE_ENGLISH_TRINIDAD,            "en", "TT" },
     170             :     { LANGUAGE_ENGLISH_ZIMBABWE,            "en", "ZW" },
     171             :     { LANGUAGE_ENGLISH_INDONESIA,           "en", "ID" },
     172             :     { LANGUAGE_ESTONIAN,                    "et", "EE" },
     173             :     { LANGUAGE_FAEROESE,                    "fo", "FO" },
     174             :     { LANGUAGE_FARSI,                       "fa", "IR" },
     175             :     { LANGUAGE_FRENCH_LUXEMBOURG,           "fr", "LU" },
     176             :     { LANGUAGE_FRENCH_MONACO,               "fr", "MC" },
     177             :     { LANGUAGE_GERMAN_LUXEMBOURG,           "de", "LU" },
     178             :     { LANGUAGE_GERMAN_LIECHTENSTEIN,        "de", "LI" },
     179             :     { LANGUAGE_HEBREW,                      "he", "IL" },   // new: old was "iw"
     180             :     { LANGUAGE_HEBREW,                      "iw", "IL" },   // old: new is "he"
     181             :     { LANGUAGE_HUNGARIAN,                   "hu", "HU" },
     182             :     { LANGUAGE_ICELANDIC,                   "is", "IS" },
     183             :     { LANGUAGE_INDONESIAN,                  "id", "ID" },   // new: old was "in"
     184             :     { LANGUAGE_INDONESIAN,                  "in", "ID" },   // old: new is "id"
     185             :     { LANGUAGE_NORWEGIAN,                   "no", "NO" },
     186             :     { LANGUAGE_NORWEGIAN_BOKMAL,            "nb", "NO" },
     187             :     { LANGUAGE_NORWEGIAN_NYNORSK,           "nn", "NO" },
     188             :     { LANGUAGE_POLISH,                      "pl", "PL" },
     189             :     { LANGUAGE_RHAETO_ROMAN,                "rm", "CH" },
     190             :     { LANGUAGE_ROMANIAN,                    "ro", "RO" },
     191             :     { LANGUAGE_ROMANIAN_MOLDOVA,            "ro", "MD" },
     192             :     { LANGUAGE_SLOVAK,                      "sk", "SK" },
     193             :     { LANGUAGE_SLOVENIAN,                   "sl", "SI" },
     194             :     { LANGUAGE_SPANISH_MEXICAN,             "es", "MX" },
     195             :     { LANGUAGE_SPANISH_GUATEMALA,           "es", "GT" },
     196             :     { LANGUAGE_SPANISH_COSTARICA,           "es", "CR" },
     197             :     { LANGUAGE_SPANISH_PANAMA,              "es", "PA" },
     198             :     { LANGUAGE_SPANISH_DOMINICAN_REPUBLIC,  "es", "DO" },
     199             :     { LANGUAGE_SPANISH_VENEZUELA,           "es", "VE" },
     200             :     { LANGUAGE_SPANISH_COLOMBIA,            "es", "CO" },
     201             :     { LANGUAGE_SPANISH_PERU,                "es", "PE" },
     202             :     { LANGUAGE_SPANISH_ARGENTINA,           "es", "AR" },
     203             :     { LANGUAGE_SPANISH_ECUADOR,             "es", "EC" },
     204             :     { LANGUAGE_SPANISH_CHILE,               "es", "CL" },
     205             :     { LANGUAGE_SPANISH_URUGUAY,             "es", "UY" },
     206             :     { LANGUAGE_SPANISH_PARAGUAY,            "es", "PY" },
     207             :     { LANGUAGE_SPANISH_BOLIVIA,             "es", "BO" },
     208             :     { LANGUAGE_SPANISH_EL_SALVADOR,         "es", "SV" },
     209             :     { LANGUAGE_SPANISH_HONDURAS,            "es", "HN" },
     210             :     { LANGUAGE_SPANISH_NICARAGUA,           "es", "NI" },
     211             :     { LANGUAGE_SPANISH_PUERTO_RICO,         "es", "PR" },
     212             :     { LANGUAGE_SPANISH_UNITED_STATES,       "es", "US" },
     213             :     { LANGUAGE_SPANISH_LATIN_AMERICA,       "es", ""   },
     214             :     { LANGUAGE_TURKISH,                     "tr", "TR" },
     215             :     { LANGUAGE_UKRAINIAN,                   "uk", "UA" },
     216             :     { LANGUAGE_VIETNAMESE,                  "vi", "VN" },
     217             :     { LANGUAGE_LATVIAN,                     "lv", "LV" },
     218             :     { LANGUAGE_MACEDONIAN,                  "mk", "MK" },
     219             :     { LANGUAGE_MALAY,                       "ms", ""   },
     220             :     { LANGUAGE_MALAY_MALAYSIA,              "ms", "MY" },
     221             :     { LANGUAGE_MALAY_BRUNEI_DARUSSALAM,     "ms", "BN" },
     222             :     { LANGUAGE_ENGLISH_MALAYSIA,            "en", "MY" },
     223             :     { LANGUAGE_THAI,                        "th", "TH" },
     224             :     { LANGUAGE_LITHUANIAN,                  "lt", "LT" },
     225             :     { LANGUAGE_LITHUANIAN_CLASSIC,          "lt", "LT" },
     226             :     { LANGUAGE_CROATIAN,                    "hr", "HR" },   // Croatian in Croatia
     227             :     { LANGUAGE_CROATIAN_BOSNIA_HERZEGOVINA, "hr", "BA" },
     228             :     { LANGUAGE_BOSNIAN_LATIN_BOSNIA_HERZEGOVINA,        "bs", "BA" },
     229             : //  { LANGUAGE_BOSNIAN_CYRILLIC_BOSNIA_AND_HERZEGOVINA, "bs", "BA" },   // script codes not supported yet
     230             :     { LANGUAGE_USER_SERBIAN_CYRILLIC_SERBIA,        "sr", "RS" },   // Serbian Cyrillic in Serbia
     231             :     { LANGUAGE_SERBIAN_CYRILLIC,                    "sr", "YU" },   // legacy Serbian Cyrillic in Serbia and Montenegro (former Yugoslavia); kludge, needed to be sr_CS instead, sr_CS not supported by ICU 2.6 (3.4 does)
     232             :     { LANGUAGE_SERBIAN_CYRILLIC,                    "sr", "CS" },   // alias to be able to integrate localizations, rsc needs it
     233             :     { LANGUAGE_USER_SERBIAN_CYRILLIC_MONTENEGRO,    "sr", "ME" },
     234             :     { LANGUAGE_SERBIAN_CYRILLIC_BOSNIA_HERZEGOVINA, "sr", "BA" },
     235             :     { LANGUAGE_SERBIAN,                             "sr", ""   },   // SERBIAN is only LID, MS-LCID not defined (was dupe of CROATIAN)
     236             :     { LANGUAGE_USER_SERBIAN_LATIN_SERBIA,           "sh", "RS" },   // Serbian Latin in Serbia; kludge, needed to be sr_Latn_RS instead, script codes not supported yet
     237             :     { LANGUAGE_SERBIAN_LATIN,                       "sh", "YU" },   // legacy Serbian Latin in Serbia and Montenegro (former Yugoslavia); kludge, needed to be sr_Latn_CS instead, script codes not supported yet
     238             :     { LANGUAGE_SERBIAN_LATIN,                       "sh", "CS" },   // Serbian Latin in Serbia and Montenegro; kludge, needed to be sr_Latn_CS instead, script codes not supported yet
     239             :     { LANGUAGE_USER_SERBIAN_LATIN_MONTENEGRO,       "sh", "ME" },   // Serbian Latin in Montenegro; kludge, needed to be sr_Latn_ME instead, script codes not supported yet
     240             :     { LANGUAGE_SERBIAN_LATIN_BOSNIA_HERZEGOVINA,    "sh", "BA" },
     241             :     { LANGUAGE_SERBIAN_LATIN_NEUTRAL,               "sh", ""   },   // kludge, needed to be sr_Latn instead, script codes not supported yet
     242             :     { LANGUAGE_ARMENIAN,                    "hy", "AM" },
     243             :     { LANGUAGE_AZERI,                       "az", ""   },
     244             :     { LANGUAGE_AZERI_LATIN,                 "az", "AZ" },
     245             : //  { LANGUAGE_AZERI_CYRILLIC,              "az", "AZ" },   // script codes not supported yet
     246             :     { LANGUAGE_UZBEK_LATIN,                 "uz", "UZ" },
     247             : //  { LANGUAGE_UZBEK_CYRILLIC,              "uz", "UZ" },   // script codes not supported yet
     248             :     { LANGUAGE_BENGALI_BANGLADESH,          "bn", "BD" },
     249             :     { LANGUAGE_BENGALI,                     "bn", "IN" },
     250             :     { LANGUAGE_BURMESE,                     "my", "MM" },
     251             :     { LANGUAGE_KAZAKH,                      "kk", "KZ" },
     252             :     { LANGUAGE_ENGLISH_INDIA,               "en", "IN" },
     253             :     { LANGUAGE_URDU,                        "ur", ""   },
     254             :     { LANGUAGE_URDU_INDIA,                  "ur", "IN" },
     255             :     { LANGUAGE_URDU_PAKISTAN,               "ur", "PK" },
     256             :     { LANGUAGE_HINDI,                       "hi", "IN" },
     257             :     { LANGUAGE_GUJARATI,                    "gu", "IN" },
     258             :     { LANGUAGE_KANNADA,                     "kn", "IN" },
     259             :     { LANGUAGE_ASSAMESE,                    "as", "IN" },
     260             :     { LANGUAGE_KASHMIRI,                    "ks", ""   },
     261             :     { LANGUAGE_KASHMIRI_INDIA,              "ks", "IN" },
     262             :     { LANGUAGE_MALAYALAM,                   "ml", "IN" },
     263             :     { LANGUAGE_MANIPURI,                   "mni", "IN" },
     264             :     { LANGUAGE_MARATHI,                     "mr", "IN" },
     265             :     { LANGUAGE_KONKANI,                    "kok", "IN" },
     266             :     { LANGUAGE_NEPALI,                      "ne", "NP" },
     267             :     { LANGUAGE_NEPALI_INDIA,                "ne", "IN" },
     268             :     { LANGUAGE_ORIYA,                       "or", "IN" },
     269             :     { LANGUAGE_PUNJABI,                     "pa", "IN" },
     270             :     { LANGUAGE_SANSKRIT,                    "sa", "IN" },
     271             :     { LANGUAGE_SINDHI,                      "sd", "IN" },
     272             :     { LANGUAGE_TAMIL,                       "ta", "IN" },
     273             :     { LANGUAGE_TELUGU,                      "te", "IN" },
     274             :     { LANGUAGE_PUNJABI_PAKISTAN,           "lah", "PK" },   // preferring "lah" over "pa" for Western Punjabi, see http://www.ethnologue.com/show_language.asp?code=PNB
     275             :     { LANGUAGE_PUNJABI_PAKISTAN,            "pa", "PK" },
     276             :     { LANGUAGE_SINDHI_PAKISTAN,             "sd", "PK" },
     277             :     { LANGUAGE_BELARUSIAN,                  "be", "BY" },
     278             :     { LANGUAGE_CATALAN,                     "ca", "ES" },   // Spain (default)
     279             :     { LANGUAGE_CATALAN,                     "ca", "AD" },   // Andorra
     280             :     { LANGUAGE_USER_CATALAN_VALENCIAN,                     "ca", "XV" },   // XV: ISO 3166 user-assigned; workaround for UI localization only, do not use in document content!
     281             :     { LANGUAGE_CATALAN,                    "qcv", "ES" },   // qcv: ISO 639-3 reserved-for-local-use; UI localization quirk only, do not use in document content!
     282             : //    { LANGUAGE_USER_CATALAN_VALENCIAN,      "ca", "ES" },   // In case MS format files escaped into the wild, map them back.
     283             :     { LANGUAGE_FRENCH_CAMEROON,             "fr", "CM" },
     284             :     { LANGUAGE_FRENCH_COTE_D_IVOIRE,        "fr", "CI" },
     285             :     { LANGUAGE_FRENCH_MALI,                 "fr", "ML" },
     286             :     { LANGUAGE_FRENCH_SENEGAL,              "fr", "SN" },
     287             :     { LANGUAGE_FRENCH_ZAIRE,                "fr", "CD" },   // Democratic Republic Of Congo
     288             :     { LANGUAGE_FRENCH_MOROCCO,              "fr", "MA" },
     289             :     { LANGUAGE_FRENCH_REUNION,              "fr", "RE" },
     290             :     { LANGUAGE_FRENCH_NORTH_AFRICA,         "fr", ""   },
     291             :     { LANGUAGE_FRENCH_WEST_INDIES,          "fr", ""   },   // unknown ISO country code
     292             :     { LANGUAGE_FRISIAN_NETHERLANDS,         "fy", "NL" },
     293             :     { LANGUAGE_GAELIC_IRELAND,              "ga", "IE" },
     294             :     { LANGUAGE_GAELIC_SCOTLAND,             "gd", "GB" },
     295             :     { LANGUAGE_GALICIAN,                    "gl", "ES" },
     296             :     { LANGUAGE_GEORGIAN,                    "ka", "GE" },
     297             :     { LANGUAGE_KHMER,                       "km", "KH" },
     298             :     { LANGUAGE_KIRGHIZ,                     "ky", "KG" },
     299             :     { LANGUAGE_LAO,                         "lo", "LA" },
     300             :     { LANGUAGE_MALTESE,                     "mt", "MT" },
     301             :     { LANGUAGE_MONGOLIAN,                   "mn", "MN" },   // Cyrillic script
     302             :     { LANGUAGE_MONGOLIAN_MONGOLIAN,         "mn", "MN" },
     303             :     { LANGUAGE_RUSSIAN_MOLDOVA,             "mo", "MD" },
     304             :     { LANGUAGE_SWAHILI,                     "sw", "KE" },
     305             :     { LANGUAGE_USER_SWAHILI_TANZANIA,       "sw", "TZ" },
     306             :     { LANGUAGE_TAJIK,                       "tg", "TJ" },
     307             :     { LANGUAGE_TIBETAN,                     "bo", "CN" },   // CN politically correct?
     308             :     { LANGUAGE_USER_TIBETAN_INDIA,          "bo", "IN" },
     309             :     { LANGUAGE_DZONGKHA,                    "dz", "BT" },
     310             :     { LANGUAGE_TURKMEN,                     "tk", "TM" },
     311             :     { LANGUAGE_WELSH,                       "cy", "GB" },
     312             :     { LANGUAGE_SESOTHO,                     "st", "ZA" },
     313             :     { LANGUAGE_SEPEDI,                     "nso", "ZA" },
     314             :     { LANGUAGE_SEPEDI,                      "ns", "ZA" },   // fake "ns" for compatibility with existing OOo1.1.x localization to be able to read those documents
     315             :     { LANGUAGE_TSONGA,                      "ts", "ZA" },
     316             :     { LANGUAGE_TSWANA,                      "tn", "ZA" },
     317             :     { LANGUAGE_ENGLISH_SAFRICA,             "en", "ZA" },
     318             :     { LANGUAGE_AFRIKAANS,                   "af", "ZA" },
     319             :     { LANGUAGE_VENDA,                       "ve", "ZA" },   // default 639-1
     320             :     { LANGUAGE_VENDA,                      "ven", "ZA" },   // 639-2 may have been used temporarily since 2004-07-23
     321             :     { LANGUAGE_XHOSA,                       "xh", "ZA" },
     322             :     { LANGUAGE_ZULU,                        "zu", "ZA" },
     323             :     { LANGUAGE_QUECHUA_ECUADOR,             "qu", "EC" },
     324             :     { LANGUAGE_QUECHUA_PERU,                "qu", "PE" },
     325             :     { LANGUAGE_QUECHUA_BOLIVIA,             "qu", "BO" },   // macro: quh-BO, qul-BO
     326             :     { LANGUAGE_PASHTO,                      "ps", "AF" },
     327             :     { LANGUAGE_OROMO,                       "om", "ET" },
     328             :     { LANGUAGE_DHIVEHI,                     "dv", "MV" },
     329             :     { LANGUAGE_UIGHUR_CHINA,                "ug", "CN" },
     330             :     { LANGUAGE_TIGRIGNA_ETHIOPIA,           "ti", "ET" },
     331             :     { LANGUAGE_TIGRIGNA_ERITREA,            "ti", "ER" },
     332             :     { LANGUAGE_AMHARIC_ETHIOPIA,            "am", "ET" },
     333             :     { LANGUAGE_GUARANI_PARAGUAY,           "gug", "PY" },
     334             :     { LANGUAGE_HAWAIIAN_UNITED_STATES,     "haw", "US" },
     335             :     { LANGUAGE_EDO,                        "bin", "NG" },
     336             :     { LANGUAGE_FULFULDE_NIGERIA,            "ff", "NG" },
     337             :     { LANGUAGE_HAUSA_NIGERIA,               "ha", "NG" },
     338             :     { LANGUAGE_USER_HAUSA_GHANA,            "ha", "GH" },
     339             :     { LANGUAGE_IGBO_NIGERIA,                "ig", "NG" },
     340             :     { LANGUAGE_KANURI_NIGERIA,              "kr", "NG" },
     341             :     { LANGUAGE_YORUBA,                      "yo", "NG" },
     342             :     { LANGUAGE_SOMALI,                      "so", "SO" },
     343             :     { LANGUAGE_PAPIAMENTU,                 "pap", "AN" },
     344             :     { LANGUAGE_USER_PAPIAMENTU_ARUBA,      "pap", "AW" },
     345             :     { LANGUAGE_USER_PAPIAMENTU_CURACAO,    "pap", "CW" },
     346             :     { LANGUAGE_USER_PAPIAMENTU_BONAIRE,    "pap", "BQ" },
     347             :     { LANGUAGE_ENGLISH_SINGAPORE,           "en", "SG" },
     348             :     { LANGUAGE_USER_YIDDISH_US,             "yi", "US" },
     349             :     { LANGUAGE_YIDDISH,                     "yi", "IL" },   // new: old was "ji"
     350             :     { LANGUAGE_YIDDISH,                     "ji", "IL" },   // old: new is "yi"
     351             :     { LANGUAGE_SYRIAC,                     "syr", "TR" },   // "TR" according to http://www.ethnologue.com/show_language.asp?code=SYC
     352             :     { LANGUAGE_SINHALESE_SRI_LANKA,         "si", "LK" },
     353             :     { LANGUAGE_CHEROKEE_UNITED_STATES,     "chr", "US" },
     354             :     { LANGUAGE_INUKTITUT_LATIN_CANADA,      "iu", "CA" },
     355             : //  { LANGUAGE_INUKTITUT_SYLLABICS_CANADA,  "iu", "CA" },   // script codes not supported yet
     356             :     { LANGUAGE_SAMI_NORTHERN_NORWAY,        "se", "NO" },
     357             :     { LANGUAGE_SAMI_INARI,                 "smn", "FI" },
     358             :     { LANGUAGE_SAMI_LULE_NORWAY,           "smj", "NO" },
     359             :     { LANGUAGE_SAMI_LULE_SWEDEN,           "smj", "SE" },
     360             :     { LANGUAGE_SAMI_NORTHERN_FINLAND,       "se", "FI" },
     361             :     { LANGUAGE_SAMI_NORTHERN_SWEDEN,        "se", "SE" },
     362             :     { LANGUAGE_SAMI_SKOLT,                 "sms", "FI" },
     363             :     { LANGUAGE_SAMI_SOUTHERN_NORWAY,       "sma", "NO" },
     364             :     { LANGUAGE_SAMI_SOUTHERN_SWEDEN,       "sma", "SE" },
     365             :     { LANGUAGE_USER_SAMI_KILDIN_RUSSIA,    "sjd", "RU" },
     366             :     { LANGUAGE_MAPUDUNGUN_CHILE,           "arn", "CL" },
     367             :     { LANGUAGE_CORSICAN_FRANCE,             "co", "FR" },
     368             :     { LANGUAGE_ALSATIAN_FRANCE,            "gsw", "FR" },   // in fact 'gsw' is Schwyzerduetsch (Swiss German), which is a dialect of Alemannic German, as is Alsatian. They aren't distinct languages and share this code.
     369             :     { LANGUAGE_YAKUT_RUSSIA,               "sah", "RU" },
     370             :     { LANGUAGE_MOHAWK_CANADA,              "moh", "CA" },
     371             :     { LANGUAGE_BASHKIR_RUSSIA,              "ba", "RU" },
     372             :     { LANGUAGE_KICHE_GUATEMALA,            "qut", "GT" },
     373             :     { LANGUAGE_DARI_AFGHANISTAN,           "gbz", "AF" },
     374             :     { LANGUAGE_WOLOF_SENEGAL,               "wo", "SN" },
     375             :     { LANGUAGE_FILIPINO,                   "fil", "PH" },
     376             :     { LANGUAGE_USER_TAGALOG,                "tl", "PH" },
     377             :     { LANGUAGE_ENGLISH_PHILIPPINES,         "en", "PH" },
     378             : //  { LANGUAGE_IBIBIO_NIGERIA,             "nic", "NG" },   // ISO "nic" is only a collective language code
     379             :     { LANGUAGE_YI,                          "ii", "CN" },
     380             :     { LANGUAGE_TAMAZIGHT_LATIN,            "kab", "DZ" },   // In practice Kabyle is the language used for this
     381             :     { LANGUAGE_OBSOLETE_USER_KABYLE,       "kab", "DZ" },
     382             :     { LANGUAGE_TAMAZIGHT_LATIN,            "ber", "DZ" },   // In practice Algeria has standardized on Kabyle as the member of the "ber" collective which gets used there.
     383             :     { LANGUAGE_TAMAZIGHT_TIFINAGH,         "ber", "MA" },   // Morocco is officially using Tifinagh for its Berber languages so store it to distinguish explicitly from LANGUAGE_TAMAZIGHT_LATIN, even though as a collective language its not of much use
     384             : //  { LANGUAGE_TAMAZIGHT_ARABIC,           "ber", ""   },   // ISO "ber" only collective!
     385             :     { LANGUAGE_LATIN,                       "la", "VA" },
     386             :     { LANGUAGE_OBSOLETE_USER_LATIN,         "la", "VA" },
     387             :     { LANGUAGE_USER_ESPERANTO,              "eo", ""   },
     388             :     { LANGUAGE_USER_INTERLINGUA,            "ia", ""   },
     389             :     { LANGUAGE_MAORI_NEW_ZEALAND,           "mi", "NZ" },
     390             :     { LANGUAGE_OBSOLETE_USER_MAORI,         "mi", "NZ" },
     391             :     { LANGUAGE_KINYARWANDA_RWANDA,          "rw", "RW" },
     392             :     { LANGUAGE_OBSOLETE_USER_KINYARWANDA,   "rw", "RW" },
     393             :     { LANGUAGE_UPPER_SORBIAN_GERMANY,      "hsb", "DE" },   // MS maps this to 'wen-DE', which is nonsense. 'wen' is a collective language code, 'WEN' is a SIL code, see http://www.ethnologue.com/14/show_iso639.asp?code=wen and http://www.ethnologue.com/14/show_language.asp?code=WEN
     394             :     { LANGUAGE_OBSOLETE_USER_UPPER_SORBIAN,"hsb", "DE" },
     395             :     { LANGUAGE_LOWER_SORBIAN_GERMANY,      "dsb", "DE" },   // MS maps this to 'wee-DE', which is nonsense. 'WEE' is a SIL code, see http://www.ethnologue.com/14/show_language.asp?code=WEE
     396             :     { LANGUAGE_OBSOLETE_USER_LOWER_SORBIAN,"dsb", "DE" },
     397             :     { LANGUAGE_OCCITAN_FRANCE,              "oc", "FR" },
     398             :     { LANGUAGE_OBSOLETE_USER_OCCITAN,       "oc", "FR" },
     399             :     { LANGUAGE_USER_KURDISH_TURKEY,         "ku", "TR" },
     400             :     { LANGUAGE_USER_KURDISH_SYRIA,          "ku", "SY" },
     401             :     { LANGUAGE_USER_KURDISH_IRAQ,           "ku", "IQ" },
     402             :     { LANGUAGE_USER_KURDISH_IRAN,           "ku", "IR" },
     403             :     { LANGUAGE_USER_SARDINIAN,              "sc", "IT" },   // macrolanguage code
     404             :     { LANGUAGE_USER_SARDINIAN_CAMPIDANESE, "sro", "IT" },
     405             :     { LANGUAGE_USER_SARDINIAN_GALLURESE,   "sdn", "IT" },
     406             :     { LANGUAGE_USER_SARDINIAN_LOGUDORESE,  "src", "IT" },
     407             :     { LANGUAGE_USER_SARDINIAN_SASSARESE,   "sdc", "IT" },
     408             :     { LANGUAGE_BRETON_FRANCE,               "br", "FR" },
     409             :     { LANGUAGE_OBSOLETE_USER_BRETON,        "br", "FR" },
     410             :     { LANGUAGE_KALAALLISUT_GREENLAND,       "kl", "GL" },
     411             :     { LANGUAGE_OBSOLETE_USER_KALAALLISUT,   "kl", "GL" },
     412             :     { LANGUAGE_USER_SWAZI,                  "ss", "ZA" },
     413             :     { LANGUAGE_USER_NDEBELE_SOUTH,          "nr", "ZA" },
     414             :     { LANGUAGE_USER_TSWANA_BOTSWANA,        "tn", "BW" },
     415             :     { LANGUAGE_USER_MOORE,                 "mos", "BF" },
     416             :     { LANGUAGE_USER_BAMBARA,                "bm", "ML" },
     417             :     { LANGUAGE_USER_AKAN,                   "ak", "GH" },
     418             :     { LANGUAGE_LUXEMBOURGISH_LUXEMBOURG,    "lb", "LU" },
     419             :     { LANGUAGE_OBSOLETE_USER_LUXEMBOURGISH, "lb", "LU" },
     420             :     { LANGUAGE_USER_FRIULIAN,              "fur", "IT" },
     421             :     { LANGUAGE_USER_FIJIAN,                 "fj", "FJ" },
     422             :     { LANGUAGE_USER_AFRIKAANS_NAMIBIA,      "af", "NA" },
     423             :     { LANGUAGE_USER_ENGLISH_NAMIBIA,        "en", "NA" },
     424             :     { LANGUAGE_USER_WALLOON,                "wa", "BE" },
     425             :     { LANGUAGE_USER_COPTIC,                "cop", "EG" },
     426             :     { LANGUAGE_USER_GASCON,                "gsc", "FR" },
     427             :     { LANGUAGE_USER_GERMAN_BELGIUM,         "de", "BE" },
     428             :     { LANGUAGE_USER_CHUVASH,                "cv", "RU" },
     429             :     { LANGUAGE_USER_EWE_GHANA,              "ee", "GH" },
     430             :     { LANGUAGE_USER_ENGLISH_GHANA,          "en", "GH" },
     431             :     { LANGUAGE_USER_SANGO,                  "sg", "CF" },
     432             :     { LANGUAGE_USER_GANDA,                  "lg", "UG" },
     433             :     { LANGUAGE_USER_LINGALA_DRCONGO,        "ln", "CD" },
     434             :     { LANGUAGE_USER_LOW_GERMAN,            "nds", "DE" },
     435             :     { LANGUAGE_USER_HILIGAYNON,            "hil", "PH" },
     436             :     { LANGUAGE_USER_ENGLISH_MALAWI,         "en", "MW" },   /* en default for MW */
     437             :     { LANGUAGE_USER_NYANJA,                 "ny", "MW" },
     438             :     { LANGUAGE_USER_KASHUBIAN,             "csb", "PL" },
     439             :     { LANGUAGE_USER_SPANISH_CUBA,           "es", "CU" },
     440             :     { LANGUAGE_USER_QUECHUA_NORTH_BOLIVIA, "qul", "BO" },
     441             :     { LANGUAGE_USER_QUECHUA_SOUTH_BOLIVIA, "quh", "BO" },
     442             :     { LANGUAGE_USER_BODO_INDIA,            "brx", "IN" },
     443             :     { LANGUAGE_USER_DOGRI_INDIA,           "dgo", "IN" },
     444             :     { LANGUAGE_USER_MAITHILI_INDIA,        "mai", "IN" },
     445             :     { LANGUAGE_USER_SANTALI_INDIA,         "sat", "IN" },
     446             :     { LANGUAGE_USER_TETUN,                 "tet", "ID" },
     447             :     { LANGUAGE_USER_TETUN_TIMOR_LESTE,     "tet", "TL" },
     448             :     { LANGUAGE_USER_TOK_PISIN,             "tpi", "PG" },
     449             :     { LANGUAGE_USER_SHUSWAP,               "shs", "CA" },
     450             :     { LANGUAGE_USER_ANCIENT_GREEK,         "grc", "GR" },
     451             :     { LANGUAGE_USER_ASTURIAN,              "ast", "ES" },
     452             :     { LANGUAGE_USER_LATGALIAN,             "ltg", "LV" },
     453             :     { LANGUAGE_USER_MAORE,                 "swb", "YT" },
     454             :     { LANGUAGE_USER_BUSHI,                 "buc", "YT" },
     455             :     { LANGUAGE_USER_TAHITIAN,               "ty", "PF" },
     456             :     { LANGUAGE_USER_MALAGASY_PLATEAU,      "plt", "MG" },
     457             :     { LANGUAGE_USER_MALAGASY_PLATEAU,       "mg", "MG" },
     458             :     { LANGUAGE_USER_BAFIA,                 "ksf", "CM" },
     459             :     { LANGUAGE_USER_GIKUYU,                 "ki", "KE" },
     460             :     { LANGUAGE_USER_RUSYN_UKRAINE,         "rue", "UA" },
     461             :     { LANGUAGE_USER_RUSYN_SLOVAKIA,        "rue", "SK" },
     462             :     { LANGUAGE_USER_LIMBU,                 "lif", "NP" },
     463             :     { LANGUAGE_USER_LOJBAN,                "jbo", ""   },
     464             :     { LANGUAGE_USER_HAITIAN,                "ht", "HT" },
     465             :     { LANGUAGE_FRENCH_HAITI,                "fr", "HT" },
     466             :     { LANGUAGE_USER_BEEMBE,                "beq", "CG" },
     467             :     { LANGUAGE_USER_BEKWEL,                "bkw", "CG" },
     468             :     { LANGUAGE_USER_KITUBA,                "mkw", "CG" },
     469             :     { LANGUAGE_USER_LARI,                  "ldi", "CG" },
     470             :     { LANGUAGE_USER_MBOCHI,                "mdw", "CG" },
     471             :     { LANGUAGE_USER_TEKE_EBOO,             "ebo", "CG" },
     472             :     { LANGUAGE_USER_TEKE_IBALI,            "tek", "CG" },
     473             :     { LANGUAGE_USER_TEKE_TYEE,             "tyx", "CG" },
     474             :     { LANGUAGE_USER_VILI,                  "vif", "CG" },
     475             :     { LANGUAGE_USER_PORTUGUESE_ANGOLA,      "pt", "AO" },
     476             :     { LANGUAGE_USER_MANX,                   "gv", "GB" },
     477             :     { LANGUAGE_USER_ARAGONESE,              "an", "ES" },
     478             :     { LANGUAGE_USER_KEYID,                 "qtz", ""   },   // key id pseudolanguage used for UI testing
     479             :     { LANGUAGE_USER_PALI_LATIN,            "pli", ""   },   // Pali with Latin script
     480             :     { LANGUAGE_USER_KYRGYZ_CHINA,           "ky", "CN" },
     481             :     { LANGUAGE_USER_KOMI_ZYRIAN,           "kpv", "RU" },
     482             :     { LANGUAGE_USER_KOMI_PERMYAK,          "koi", "RU" },
     483             :     { LANGUAGE_USER_PITJANTJATJARA,        "pjt", "AU" },
     484             :     { LANGUAGE_USER_ERZYA,                 "myv", "RU" },
     485             :     { LANGUAGE_USER_MARI_MEADOW,           "mhr", "RU" },
     486             :     { LANGUAGE_USER_KHANTY,                "kca", "RU" },
     487             :     { LANGUAGE_USER_LIVONIAN,              "liv", "RU" },
     488             :     { LANGUAGE_USER_MOKSHA,                "mdf", "RU" },
     489             :     { LANGUAGE_USER_MARI_HILL,             "mrj", "RU" },
     490             :     { LANGUAGE_USER_NGANASAN,              "nio", "RU" },
     491             :     { LANGUAGE_USER_OLONETS,               "olo", "RU" },
     492             :     { LANGUAGE_USER_VEPS,                  "vep", "RU" },
     493             :     { LANGUAGE_USER_VORO,                  "vro", "EE" },
     494             :     { LANGUAGE_USER_NENETS,                "yrk", "RU" },
     495             :     { LANGUAGE_USER_AKA,                   "axk", "CF" },
     496             :     { LANGUAGE_USER_AKA_CONGO,             "axk", "CG" },
     497             :     { LANGUAGE_USER_DIBOLE,                "bvx", "CG" },
     498             :     { LANGUAGE_USER_DOONDO,                "dde", "CG" },
     499             :     { LANGUAGE_USER_KAAMBA,                "xku", "CG" },
     500             :     { LANGUAGE_USER_KOONGO,                "kng", "CD" },
     501             :     { LANGUAGE_USER_KOONGO_CONGO,          "kng", "CG" },
     502             :     { LANGUAGE_USER_KUNYI,                 "njx", "CG" },
     503             :     { LANGUAGE_USER_NGUNGWEL,              "ngz", "CG" },
     504             :     { LANGUAGE_USER_NJYEM,                 "njy", "CM" },
     505             :     { LANGUAGE_USER_NJYEM_CONGO,           "njy", "CG" },
     506             :     { LANGUAGE_USER_PUNU,                  "puu", "GA" },
     507             :     { LANGUAGE_USER_PUNU_CONGO,            "puu", "CG" },
     508             :     { LANGUAGE_USER_SUUNDI,                "sdj", "CG" },
     509             :     { LANGUAGE_USER_TEKE_KUKUYA,           "kkw", "CG" },
     510             :     { LANGUAGE_USER_TSAANGI,               "tsa", "CG" },
     511             :     { LANGUAGE_USER_YAKA,                  "iyx", "CG" },
     512             :     { LANGUAGE_USER_YOMBE,                 "yom", "CD" },
     513             :     { LANGUAGE_USER_YOMBE_CONGO,           "yom", "CG" },
     514             :     { LANGUAGE_USER_SIDAMA,                "sid", "ET" },
     515             :     { LANGUAGE_USER_NKO,                   "nqo", "GN" },
     516             :     { LANGUAGE_USER_UDMURT,                "udm", "RU" },
     517             :     { LANGUAGE_USER_CORNISH,               "kw",  "UK" },
     518             :     { LANGUAGE_USER_SAMI_PITE_SWEDEN,      "sje", "SE" },
     519             :     { LANGUAGE_USER_NGAEBERE,              "gym", "PA" },
     520             :     { LANGUAGE_MULTIPLE,                   "mul", ""   },   // multiple languages, many languages are used
     521             :     { LANGUAGE_UNDETERMINED,               "und", ""   },   // undetermined language, language cannot be identified
     522             :     { LANGUAGE_NONE,                       "zxx", ""   },   // added to ISO 639-2 on 2006-01-11: Used to declare the absence of linguistic information
     523             :     { LANGUAGE_DONTKNOW,                    "",   ""   }    // marks end of table
     524             : };
     525             : 
     526             : static MsLangId::IsoLangEntry aLastResortFallbackEntry =
     527             : { LANGUAGE_ENGLISH_US, "en", "US" };
     528             : 
     529      265438 : OUString MsLangId::IsoLangEntry::getTagString() const
     530             : {
     531      265438 :     if (maCountry[0])
     532      250971 :         return OUString( OUString::createFromAscii( maLangStr) + "-" + OUString::createFromAscii( maCountry));
     533             :     else
     534       14467 :         return OUString::createFromAscii( maLangStr);
     535             : }
     536             : 
     537             : // -----------------------------------------------------------------------
     538             : 
     539             : // In this table are the countries which should mapped to a specific
     540             : // english language
     541             : static IsoLangEngEntry const aImplIsoLangEngEntries[] =
     542             : {
     543             :     { LANGUAGE_ENGLISH_UK,                  "AO" },         // Angola
     544             :     { LANGUAGE_ENGLISH_UK,                  "BJ" },         // Benin
     545             :     { LANGUAGE_ENGLISH_UK,                  "BW" },         // Botswana
     546             :     { LANGUAGE_ENGLISH_UK,                  "BI" },         // Burundi
     547             :     { LANGUAGE_ENGLISH_UK,                  "CM" },         // Cameroon
     548             :     { LANGUAGE_ENGLISH_UK,                  "GA" },         // Gabon
     549             :     { LANGUAGE_ENGLISH_UK,                  "GM" },         // Gambia
     550             :     { LANGUAGE_ENGLISH_UK,                  "GH" },         // Ghana
     551             :     { LANGUAGE_ENGLISH_UK,                  "GN" },         // Guinea
     552             :     { LANGUAGE_ENGLISH_UK,                  "LS" },         // Lesotho
     553             :     { LANGUAGE_ENGLISH_UK,                  "MW" },         // Malawi
     554             :     { LANGUAGE_ENGLISH_UK,                  "MT" },         // Malta
     555             :     { LANGUAGE_ENGLISH_UK,                  "NA" },         // Namibia
     556             :     { LANGUAGE_ENGLISH_UK,                  "NG" },         // Nigeria
     557             :     { LANGUAGE_ENGLISH_UK,                  "UG" },         // Uganda
     558             :     { LANGUAGE_ENGLISH_UK,                  "ZM" },         // Zambia
     559             :     { LANGUAGE_ENGLISH_UK,                  "ZW" },         // Zimbabwe
     560             :     { LANGUAGE_ENGLISH_UK,                  "SZ" },         // Swaziland
     561             :     { LANGUAGE_ENGLISH_UK,                  "NG" },         // Sierra Leone
     562             :     { LANGUAGE_ENGLISH_UK,                  "KN" },         // Saint Kitts and Nevis
     563             :     { LANGUAGE_ENGLISH_UK,                  "SH" },         // St. Helena
     564             :     { LANGUAGE_ENGLISH_UK,                  "IO" },         // British Indian Oceanic Territory
     565             :     { LANGUAGE_ENGLISH_UK,                  "FK" },         // Falkland Islands
     566             :     { LANGUAGE_ENGLISH_UK,                  "GI" },         // Gibraltar
     567             :     { LANGUAGE_ENGLISH_UK,                  "KI" },         // Kiribati
     568             :     { LANGUAGE_ENGLISH_UK,                  "VG" },         // Virgin Islands
     569             :     { LANGUAGE_ENGLISH_UK,                  "MU" },         // Mauritius
     570             :     { LANGUAGE_ENGLISH_UK,                  "FJ" },         // Fiji
     571             :     { LANGUAGE_ENGLISH_US,                  "KI" },         // Kiribati
     572             :     { LANGUAGE_ENGLISH_US,                  "LR" },         // Liberia
     573             :     { LANGUAGE_ENGLISH_US,                  "GU" },         // Guam
     574             :     { LANGUAGE_ENGLISH_US,                  "MH" },         // Marshall Islands
     575             :     { LANGUAGE_ENGLISH_US,                  "PW" },         // Palau
     576             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "AI" },         // Anguilla
     577             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "AG" },         // Antigua and Barbuda
     578             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "BS" },         // Bahamas
     579             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "BB" },         // Barbedos
     580             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "BM" },         // Bermuda
     581             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "KY" },         // Cayman Islands
     582             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "GD" },         // Grenada
     583             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "DM" },         // Dominica
     584             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "HT" },         // Haiti
     585             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "MS" },         // Montserrat
     586             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "FM" },         // Micronesia
     587             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "VC" },         // St. Vincent / Grenadines
     588             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "LC" },         // Saint Lucia
     589             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "TC" },         // Turks & Caicos Islands
     590             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "GY" },         // Guyana
     591             :     { LANGUAGE_ENGLISH_CARRIBEAN,           "TT" },         // Trinidad and Tobago
     592             :     { LANGUAGE_ENGLISH_AUS,                 "CX" },         // Christmas Islands
     593             :     { LANGUAGE_ENGLISH_AUS,                 "CC" },         // Cocos (Keeling) Islands
     594             :     { LANGUAGE_ENGLISH_AUS,                 "NF" },         // Norfolk Island
     595             :     { LANGUAGE_ENGLISH_AUS,                 "PG" },         // Papua New Guinea
     596             :     { LANGUAGE_ENGLISH_AUS,                 "SB" },         // Solomon Islands
     597             :     { LANGUAGE_ENGLISH_AUS,                 "TV" },         // Tuvalu
     598             :     { LANGUAGE_ENGLISH_AUS,                 "NR" },         // Nauru
     599             :     { LANGUAGE_ENGLISH_NZ,                  "CK" },         // Cook Islands
     600             :     { LANGUAGE_ENGLISH_NZ,                  "NU" },         // Niue
     601             :     { LANGUAGE_ENGLISH_NZ,                  "TK" },         // Tokelau
     602             :     { LANGUAGE_ENGLISH_NZ,                  "TO" },         // Tonga
     603             :     { LANGUAGE_DONTKNOW,                    ""   }          // marks end of table
     604             : };
     605             : 
     606             : // -----------------------------------------------------------------------
     607             : 
     608             : static IsoLangNoneStdEntry const aImplIsoNoneStdLangEntries[] =
     609             : {
     610             :     { LANGUAGE_NORWEGIAN_BOKMAL,            "no", "BOK"      }, // registered subtags for "no" in rfc1766
     611             :     { LANGUAGE_NORWEGIAN_NYNORSK,           "no", "NYN"      }, // registered subtags for "no" in rfc1766
     612             :     { LANGUAGE_SERBIAN_LATIN,               "sr", "latin"    },
     613             :     { LANGUAGE_SERBIAN_CYRILLIC,            "sr", "cyrillic" },
     614             :     { LANGUAGE_AZERI_LATIN,                 "az", "latin"    },
     615             :     { LANGUAGE_AZERI_CYRILLIC,              "az", "cyrillic" },
     616             :     { LANGUAGE_DONTKNOW,                    "",   ""         }  // marks end of table
     617             : };
     618             : 
     619             : // -----------------------------------------------------------------------
     620             : 
     621             : // in this table are only names to find the best language
     622             : static IsoLangNoneStdEntry const aImplIsoNoneStdLangEntries2[] =
     623             : {
     624             :     { LANGUAGE_NORWEGIAN_BOKMAL,            "no", "bokmaal"  },
     625             :     { LANGUAGE_NORWEGIAN_BOKMAL,            "no", "bokmal"   },
     626             :     { LANGUAGE_NORWEGIAN_NYNORSK,           "no", "nynorsk"  },
     627             :     { LANGUAGE_DONTKNOW,                    "",   ""         }  // marks end of table
     628             : };
     629             : 
     630             : // -----------------------------------------------------------------------
     631             : 
     632             : // in this table are only names to find the best language
     633             : static IsoLangOtherEntry const aImplOtherEntries[] =
     634             : {
     635             :     { LANGUAGE_ENGLISH_US,                  "c"              },
     636             :     { LANGUAGE_CHINESE,                     "chinese"        },
     637             :     { LANGUAGE_GERMAN,                      "german"         },
     638             :     { LANGUAGE_JAPANESE,                    "japanese"       },
     639             :     { LANGUAGE_KOREAN,                      "korean"         },
     640             :     { LANGUAGE_ENGLISH_US,                  "posix"          },
     641             :     { LANGUAGE_CHINESE_TRADITIONAL,         "tchinese"       },
     642             :     { LANGUAGE_DONTKNOW,                    NULL             }  // marks end of table
     643             : };
     644             : 
     645             : 
     646             : // in this table are only privateuse names
     647             : static IsoLangOtherEntry const aImplPrivateUseEntries[] =
     648             : {
     649             :     { LANGUAGE_USER_PRIV_NOTRANSLATE,       "x-no-translate" }, //! not BCP47 but legacy in .xcu configmgr
     650             :     { LANGUAGE_USER_PRIV_DEFAULT,           "x-default"      },
     651             :     { LANGUAGE_USER_PRIV_COMMENT,           "x-comment"      },
     652             :     { LANGUAGE_USER_PRIV_JOKER,             "*"              }, //! not BCP47 but transferable in configmgr
     653             :     { LANGUAGE_DONTKNOW,                    NULL             }  // marks end of table
     654             : };
     655             : 
     656             : // =======================================================================
     657             : 
     658             : // static
     659     1276852 : void MsLangId::Conversion::convertLanguageToIsoNames( LanguageType nLang,
     660             :         OUString& rLangStr, OUString& rCountry )
     661             : {
     662     1276852 :     if ( nLang == LANGUAGE_SYSTEM )
     663           0 :         nLang = MsLangId::getSystemLanguage();
     664             : 
     665             :     // Search for LangID (in this table we find only defined ISO combinations)
     666     1276852 :     const IsoLangEntry* pEntry = aImplIsoLangEntries;
     667    52355148 :     do
     668             :     {
     669    53631377 :         if ( pEntry->mnLang == nLang )
     670             :         {
     671     1276229 :             rLangStr = OUString::createFromAscii( pEntry->maLangStr );
     672     1276229 :             rCountry = OUString::createFromAscii( pEntry->maCountry );
     673     1276229 :             return;
     674             :         }
     675    52355148 :         ++pEntry;
     676             :     }
     677    52355148 :     while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
     678             : 
     679             :     // Search for LangID if we didn't find a specific ISO combination.
     680             :     // All entries in this table are allowed for mime specifications,
     681             :     // but not defined ISO combinations.
     682         623 :     const IsoLangNoneStdEntry* pNoneStdEntry = aImplIsoNoneStdLangEntries;
     683        3738 :     do
     684             :     {
     685        3738 :         if ( pNoneStdEntry->mnLang == nLang )
     686             :         {
     687           0 :             rLangStr = OUString::createFromAscii( pNoneStdEntry->maLangStr );
     688           0 :             rCountry = OUString::createFromAscii( pNoneStdEntry->maCountry );
     689           0 :             return;
     690             :         }
     691        3738 :         ++pNoneStdEntry;
     692             :     }
     693        3738 :     while ( pNoneStdEntry->mnLang != LANGUAGE_DONTKNOW );
     694             : 
     695             :     // Look for privateuse definitions.
     696         623 :     const IsoLangOtherEntry* pPrivateEntry = aImplPrivateUseEntries;
     697           3 :     do
     698             :     {
     699         626 :         if ( pPrivateEntry->mnLang == nLang )
     700             :         {
     701         623 :             rLangStr = OUString::createFromAscii( pPrivateEntry->mpLangStr );
     702         623 :             rCountry = OUString();
     703         623 :             return;
     704             :         }
     705           3 :         ++pPrivateEntry;
     706             :     }
     707           3 :     while ( pPrivateEntry->mnLang != LANGUAGE_DONTKNOW );
     708             : 
     709             :     // not found
     710           0 :     rLangStr = OUString();
     711           0 :     rCountry = OUString();
     712             : }
     713             : 
     714             : // -----------------------------------------------------------------------
     715             : 
     716             : // -----------------------------------------------------------------------
     717             : 
     718          38 : static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry( LanguageType nLang )
     719             : {
     720          38 :     LanguageType nPrimary = MsLangId::getPrimaryLanguage( nLang);
     721             : 
     722             :     // Search for LangID and remember first lang-only.
     723          38 :     const MsLangId::IsoLangEntry* pFirstPrimary = NULL;
     724          38 :     const MsLangId::IsoLangEntry* pEntry = aImplIsoLangEntries;
     725          38 :     do
     726             :     {
     727          76 :         if (pEntry->mnLang == nLang)
     728             :         {
     729          38 :             if (*pEntry->maCountry)
     730          38 :                 return *pEntry;
     731           0 :             switch (nLang)
     732             :             {
     733             :                 // These are known to have no country assigned.
     734             :                 case LANGUAGE_BASQUE:
     735             :                 case LANGUAGE_USER_ESPERANTO:
     736             :                 case LANGUAGE_USER_INTERLINGUA:
     737             :                 case LANGUAGE_USER_LOJBAN:
     738           0 :                     return *pEntry;
     739             :                 default:
     740             :                     ;   // nothing
     741             :             }
     742             :         }
     743          76 :         if (!pFirstPrimary &&
     744          38 :                 MsLangId::getPrimaryLanguage( pEntry->mnLang) == nPrimary)
     745          38 :             pFirstPrimary = pEntry;
     746          38 :         ++pEntry;
     747             :     }
     748          38 :     while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
     749             : 
     750             :     // Language not found at all => use default.
     751           0 :     if (!pFirstPrimary)
     752           0 :         return aLastResortFallbackEntry;
     753             : 
     754             :     // Search for first entry of primary language with any country.
     755           0 :     pEntry = pFirstPrimary;
     756           0 :     do
     757             :     {
     758           0 :         if (MsLangId::getPrimaryLanguage( pEntry->mnLang) == nLang)
     759             :         {
     760           0 :             if (*pEntry->maCountry)
     761           0 :                 return *pEntry;
     762             :         }
     763           0 :         ++pEntry;
     764             :     }
     765           0 :     while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
     766             : 
     767           0 :     return aLastResortFallbackEntry;
     768             : }
     769             : 
     770             : // static
     771           0 : LanguageType MsLangId::Conversion::lookupFallbackLanguage( LanguageType nLang )
     772             : {
     773           0 :     return lcl_lookupFallbackEntry( nLang).mnLang;
     774             : }
     775             : 
     776             : 
     777             : // static
     778          38 : ::com::sun::star::lang::Locale MsLangId::Conversion::lookupFallbackLocale( LanguageType nLang )
     779             : {
     780          38 :     const MsLangId::IsoLangEntry& rEntry = lcl_lookupFallbackEntry( nLang);
     781             :     return ::com::sun::star::lang::Locale(
     782             :             OUString::createFromAscii( rEntry.maLangStr),
     783             :             OUString::createFromAscii( rEntry.maCountry),
     784          38 :             OUString());
     785             : }
     786             : 
     787             : // -----------------------------------------------------------------------
     788             : 
     789         362 : static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry(
     790             :         const ::com::sun::star::lang::Locale & rLocale )
     791             : {
     792             :     // language is lower case in table
     793         362 :     OUString aLowerLang = rLocale.Language.toAsciiLowerCase();
     794             :     // country is upper case in table
     795         724 :     OUString aUpperCountry = rLocale.Country.toAsciiUpperCase();
     796         362 :     sal_Int32 nCountryLen = aUpperCountry.getLength();
     797             : 
     798             :     // Search for locale and remember first lang-only.
     799         362 :     const MsLangId::IsoLangEntry* pFirstLang = NULL;
     800         362 :     const MsLangId::IsoLangEntry* pEntry = aImplIsoLangEntries;
     801       87546 :     do
     802             :     {
     803       87886 :         if (aLowerLang.equalsAscii( pEntry->maLangStr))
     804             :         {
     805         663 :             if (*pEntry->maCountry)
     806             :             {
     807         302 :                 if (nCountryLen && aUpperCountry.equalsAscii( pEntry->maCountry))
     808          28 :                     return *pEntry;
     809             :             }
     810             :             else
     811             :             {
     812         361 :                 switch (pEntry->mnLang)
     813             :                 {
     814             :                     // These are known to have no country assigned.
     815             :                     case LANGUAGE_BASQUE:
     816             :                     case LANGUAGE_USER_ESPERANTO:
     817             :                     case LANGUAGE_USER_INTERLINGUA:
     818             :                     case LANGUAGE_USER_LOJBAN:
     819         312 :                         return *pEntry;
     820             :                     default:
     821             :                         ;   // nothing
     822             :                 }
     823             :             }
     824         323 :             if (!pFirstLang)
     825          50 :                 pFirstLang = pEntry;
     826             :         }
     827       87546 :         ++pEntry;
     828             :     }
     829       87546 :     while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
     830             : 
     831             :     // Language not found at all => use default.
     832          22 :     if (!pFirstLang)
     833           0 :         return aLastResortFallbackEntry;
     834             : 
     835             :     // Search for first entry of language with any country.
     836          22 :     pEntry = pFirstLang;
     837          21 :     do
     838             :     {
     839          35 :         if (aLowerLang.equalsAscii( pEntry->maLangStr))
     840             :         {
     841          35 :             if (*pEntry->maCountry)
     842          14 :                 return *pEntry;
     843             :         }
     844          21 :         ++pEntry;
     845             :     }
     846          21 :     while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
     847             : 
     848         370 :     return aLastResortFallbackEntry;
     849             : }
     850             : 
     851             : 
     852             : // static
     853         362 : ::com::sun::star::lang::Locale MsLangId::Conversion::lookupFallbackLocale(
     854             :         const ::com::sun::star::lang::Locale & rLocale )
     855             : {
     856         362 :     const MsLangId::IsoLangEntry& rEntry = lcl_lookupFallbackEntry( rLocale);
     857             :     return ::com::sun::star::lang::Locale(
     858             :             OUString::createFromAscii( rEntry.maLangStr),
     859             :             OUString::createFromAscii( rEntry.maCountry),
     860         362 :             OUString());
     861             : }
     862             : 
     863             : // =======================================================================
     864             : 
     865             : // static
     866          13 : LanguageType MsLangId::Conversion::convertPrivateUseToLanguage( const OUString& rPriv )
     867             : {
     868          13 :     const IsoLangOtherEntry* pPrivateEntry = aImplPrivateUseEntries;
     869          45 :     do
     870             :     {
     871          50 :         if ( rPriv.equalsIgnoreAsciiCaseAscii( pPrivateEntry->mpLangStr ) )
     872           5 :             return pPrivateEntry->mnLang;
     873          45 :         ++pPrivateEntry;
     874          45 :     } while ( pPrivateEntry->mnLang != LANGUAGE_DONTKNOW );
     875           8 :     return LANGUAGE_DONTKNOW;
     876             : }
     877             : 
     878             : 
     879             : // static
     880      411874 : LanguageType MsLangId::Conversion::convertIsoNamesToLanguage( const OUString& rLang,
     881             :         const OUString& rCountry )
     882             : {
     883             :     // language is lower case in table
     884      411874 :     OUString aLowerLang = rLang.toAsciiLowerCase();
     885             :     // country is upper case in table
     886      823748 :     OUString aUpperCountry = rCountry.toAsciiUpperCase();
     887             : 
     888             :     //  first look for exact match
     889      411874 :     const IsoLangEntry* pFirstLang = NULL;
     890      411874 :     const IsoLangEntry* pEntry = aImplIsoLangEntries;
     891    49035950 :     do
     892             :     {
     893    49447546 :         if ( aLowerLang.equalsAscii( pEntry->maLangStr ) )
     894             :         {
     895     1499149 :             if ( aUpperCountry.isEmpty() ||
     896      693627 :                  aUpperCountry.equalsAscii( pEntry->maCountry ) )
     897      411596 :                 return pEntry->mnLang;
     898      393926 :             if ( !pFirstLang )
     899      294791 :                 pFirstLang = pEntry;
     900       99135 :             else if ( !*pEntry->maCountry )
     901         134 :                 pFirstLang = pEntry;
     902             :         }
     903    49035950 :         ++pEntry;
     904             :     }
     905    49035950 :     while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
     906             : 
     907             :     // some eng countries should be mapped to a specific english language
     908         278 :     if ( aLowerLang == "en" )
     909             :     {
     910         272 :         const IsoLangEngEntry* pEngEntry = aImplIsoLangEngEntries;
     911        7548 :         do
     912             :         {
     913        7752 :             if ( aUpperCountry.equalsAscii( pEngEntry->maCountry ) )
     914         204 :                 return pEngEntry->mnLang;
     915        7548 :             ++pEngEntry;
     916             :         }
     917        7548 :         while ( pEngEntry->mnLang != LANGUAGE_DONTKNOW );
     918             :     }
     919             : 
     920             :     // test for specific languages which are not used standard ISO 3166 codes
     921          74 :     const IsoLangNoneStdEntry* pNoneStdEntry = aImplIsoNoneStdLangEntries;
     922         444 :     do
     923             :     {
     924         444 :         if ( aLowerLang.equalsAscii( pNoneStdEntry->maLangStr ) )
     925             :         {
     926             :             // The countries in this table are not all in upper case
     927           0 :             if ( aUpperCountry.equalsIgnoreAsciiCaseAscii( pNoneStdEntry->maCountry ) )
     928           0 :                 return pNoneStdEntry->mnLang;
     929             :         }
     930         444 :         ++pNoneStdEntry;
     931             :     }
     932         444 :     while ( pNoneStdEntry->mnLang != LANGUAGE_DONTKNOW );
     933          74 :     pNoneStdEntry = aImplIsoNoneStdLangEntries2;
     934         222 :     do
     935             :     {
     936         222 :         if ( aLowerLang.equalsAscii( pNoneStdEntry->maLangStr ) )
     937             :         {
     938             :             // The countries in this table are not all in upper case
     939           0 :             if ( aUpperCountry.equalsIgnoreAsciiCaseAscii( pNoneStdEntry->maCountry ) )
     940           0 :                 return pNoneStdEntry->mnLang;
     941             :         }
     942         222 :         ++pNoneStdEntry;
     943             :     }
     944         222 :     while ( pNoneStdEntry->mnLang != LANGUAGE_DONTKNOW );
     945             : 
     946             :     // If the language is correct, than we return the default language
     947          74 :     if ( pFirstLang )
     948          68 :         return pFirstLang->mnLang;
     949             : 
     950             :     //  if only the country is set, look for any entry matching the country
     951             :     //  (to allow reading country and language in separate steps, in any order)
     952           6 :     if ( !rCountry.isEmpty() && rLang.isEmpty() )
     953             :     {
     954           0 :         const IsoLangEntry* pEntry2 = aImplIsoLangEntries;
     955           0 :         do
     956             :         {
     957           0 :             if ( aUpperCountry.equalsAscii( pEntry2->maCountry ) )
     958           0 :                 return pEntry2->mnLang;
     959           0 :             ++pEntry2;
     960             :         }
     961           0 :         while ( pEntry2->mnLang != LANGUAGE_DONTKNOW );
     962             : 
     963           0 :         aLowerLang = aUpperCountry.toAsciiLowerCase();
     964             :     }
     965             : 
     966             :     // Look for privateuse definitions.
     967           6 :     LanguageType nLang = convertPrivateUseToLanguage( aLowerLang);
     968           6 :     if (nLang != LANGUAGE_DONTKNOW)
     969           0 :         return nLang;
     970             : 
     971             :     // Now look for all other definitions, which are not standard
     972           6 :     const IsoLangOtherEntry* pOtherEntry = aImplOtherEntries;
     973          42 :     do
     974             :     {
     975          42 :         if ( aLowerLang.equalsAscii( pOtherEntry->mpLangStr ) )
     976           0 :             return pOtherEntry->mnLang;
     977          42 :         ++pOtherEntry;
     978             :     }
     979          42 :     while ( pOtherEntry->mnLang != LANGUAGE_DONTKNOW );
     980             : 
     981      411880 :     return LANGUAGE_DONTKNOW;
     982             : }
     983             : 
     984             : // -----------------------------------------------------------------------
     985             : 
     986             : // static
     987         433 : LanguageType MsLangId::Conversion::convertIsoNamesToLanguage( const OString& rLang,
     988             :         const OString& rCountry )
     989             : {
     990         433 :     OUString aLang = OStringToOUString( rLang, RTL_TEXTENCODING_ASCII_US);
     991         866 :     OUString aCountry = OStringToOUString( rCountry, RTL_TEXTENCODING_ASCII_US);
     992         866 :     return convertIsoNamesToLanguage( aLang, aCountry);
     993             : }
     994             : 
     995             : // -----------------------------------------------------------------------
     996             : 
     997             : struct IsoLangGLIBCModifiersEntry
     998             : {
     999             :     LanguageType  mnLang;
    1000             :     sal_Char      maLangStr[4];
    1001             :     sal_Char      maCountry[3];
    1002             :     sal_Char      maAtString[9];
    1003             : };
    1004             : 
    1005             : static IsoLangGLIBCModifiersEntry const aImplIsoLangGLIBCModifiersEntries[] =
    1006             : {
    1007             :     // MS-LANGID codes               ISO639-1/2/3 ISO3166            glibc modifier
    1008             :     { LANGUAGE_BOSNIAN_CYRILLIC_BOSNIA_HERZEGOVINA, "bs", "BA", "cyrillic" },
    1009             :     { LANGUAGE_USER_SERBIAN_LATIN_SERBIA,           "sr", "RS", "latin" },   // Serbian Latin in Serbia
    1010             :     { LANGUAGE_SERBIAN_LATIN,                       "sr", "CS", "latin" },   // Serbian Latin in Serbia and Montenegro
    1011             :     { LANGUAGE_USER_SERBIAN_LATIN_MONTENEGRO,       "sr", "ME", "latin" },   // Serbian Latin in Montenegro
    1012             :     { LANGUAGE_SERBIAN_LATIN_NEUTRAL,               "sr", "",   "latin" },
    1013             :     { LANGUAGE_AZERI_CYRILLIC,                      "az", "AZ", "cyrillic" },
    1014             :     { LANGUAGE_UZBEK_CYRILLIC,                      "uz", "UZ", "cyrillic" },
    1015             :     { LANGUAGE_DONTKNOW,                            "",   "",   ""   }       // marks end of table
    1016             : };
    1017             : 
    1018             : // convert a unix locale string into LanguageType
    1019             : 
    1020             : // static
    1021         433 : LanguageType MsLangId::convertUnxByteStringToLanguage(
    1022             :         const OString& rString )
    1023             : {
    1024         433 :     OString  aLang;
    1025         866 :     OString  aCountry;
    1026         866 :     OString  aAtString;
    1027             : 
    1028         433 :     sal_Int32  nLangSepPos    = rString.indexOf( (sal_Char)'_' );
    1029         433 :     sal_Int32  nCountrySepPos = rString.indexOf( (sal_Char)'.' );
    1030         433 :     sal_Int32  nAtPos         = rString.indexOf( (sal_Char)'@' );
    1031             : 
    1032         433 :     if (nCountrySepPos < 0)
    1033           0 :         nCountrySepPos = nAtPos;
    1034         433 :     if (nCountrySepPos < 0)
    1035           0 :         nCountrySepPos = rString.getLength();
    1036             : 
    1037         433 :     if (nAtPos >= 0)
    1038           0 :         aAtString = rString.copy( nAtPos+1 );
    1039             : 
    1040         433 :     if (   ((nLangSepPos >= 0) && (nLangSepPos > nCountrySepPos))
    1041         433 :         || ((nLangSepPos < 0)) )
    1042             :     {
    1043             :         // eg. "el.sun_eu_greek", "tchinese", "es.ISO8859-15"
    1044           0 :         aLang    = rString.copy( 0, nCountrySepPos );
    1045             :     }
    1046         433 :     else if ( nLangSepPos >= 0 )
    1047             :     {
    1048             :         // well formed iso names like "en_US.UTF-8", "sh_BA.ISO8859-2@bosnia"
    1049         433 :         aLang    = rString.copy( 0, nLangSepPos );
    1050         433 :         aCountry = rString.copy( nLangSepPos+1, nCountrySepPos - nLangSepPos - 1);
    1051             :     }
    1052             : 
    1053             :     //  if there is a glibc modifier, first look for exact match in modifier table
    1054         433 :     if (!aAtString.isEmpty())
    1055             :     {
    1056             :         // language is lower case in table
    1057           0 :         OString aLowerLang = aLang.toAsciiLowerCase();
    1058             :         // country is upper case in table
    1059           0 :         OString aUpperCountry = aCountry.toAsciiUpperCase();
    1060           0 :         const IsoLangGLIBCModifiersEntry* pGLIBCModifiersEntry = aImplIsoLangGLIBCModifiersEntries;
    1061           0 :         do
    1062             :         {                         // avoid embedded \0 warning
    1063           0 :             if (( aLowerLang.equals( static_cast< const char* >( pGLIBCModifiersEntry->maLangStr ))) &&
    1064           0 :                ( aAtString.equals( static_cast< const char* >( pGLIBCModifiersEntry->maAtString ))))
    1065             :             {
    1066           0 :                 if ( aUpperCountry.isEmpty() ||
    1067           0 :                      aUpperCountry.equals( static_cast< const char* >( pGLIBCModifiersEntry->maCountry )))
    1068             :                {
    1069           0 :                     return pGLIBCModifiersEntry->mnLang;
    1070             :                }
    1071             :             }
    1072           0 :             ++pGLIBCModifiersEntry;
    1073             :         }
    1074           0 :         while ( pGLIBCModifiersEntry->mnLang != LANGUAGE_DONTKNOW );
    1075             :     }
    1076             : 
    1077         866 :     return Conversion::convertIsoNamesToLanguage( aLang, aCountry );
    1078             : }
    1079             : 
    1080             : // -----------------------------------------------------------------------
    1081             : // pass one IsoLangEntry to the outer world of the resource compiler
    1082             : 
    1083             : // static
    1084      265221 : const MsLangId::IsoLangEntry* MsLangId::getIsoLangEntry( size_t nIndex )
    1085             : {
    1086      265221 :     if (nIndex < SAL_N_ELEMENTS(aImplIsoLangEntries))
    1087      265221 :         return &aImplIsoLangEntries[ nIndex];
    1088           0 :     return 0;
    1089             : }
    1090             : 
    1091             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10