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