1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/log.hxx>
21 #include <o3tl/string_view.hxx>
22 #include <rtl/ustring.hxx>
23 #include <rtl/string.hxx>
25 #include <i18nlangtag/mslangid.hxx>
26 #include <i18nlangtag/languagetag.hxx>
28 using namespace com::sun::star
;
31 constexpr LanguageType
k0(0);
32 constexpr LanguageType
kSAME(0xffff);
35 LanguageType
getOverrideLang( LanguageType nLang
, LanguageType nOverride
)
37 return nOverride
? ((nOverride
== kSAME
) ? nLang
: nOverride
) : nLang
;
41 /* Usage of override mechanism:
42 * If a table entry's mnOverride is not 0, an override entry with an mnLang
43 * value of (mnOverride==kSAME ? mnLang : mnOverride) exists that should be
44 * used instead. There MUST exist one such entry that does not have an
45 * mnOverride value and within one table it MUST be located before any entry
46 * with that mnLang and an mnOverride value of not 0. Usually kSAME is used as
47 * override value, with rare exceptions, see tables below.
49 * The override serves these purposes:
50 * - With getOverride() it indicates that there is a different language tag
51 * (locale) that the requested language tag should be "canonicalized" to.
52 * - With lookupFallbackLocale() a locale may be returned where the language
54 * - With convertLanguageToLocaleImpl() and bIgnoreOverride=false the override
55 * is followed and the override locale returned.
56 * - With convertLocaleToLanguageImpl() a different LangID may be returned in
57 * rare cases where the actual mapped ID differs.
60 struct IsoLanguageCountryEntry
65 LanguageType mnOverride
;
67 /** Obtain a language tag string with '-' separator. */
68 OUString
getTagString() const;
70 /** Obtain a locale. */
71 css::lang::Locale
getLocale() const;
74 struct IsoLanguageScriptCountryEntry
77 char maLanguageScript
[9]; ///< "ll-Ssss" or "lll-Ssss"
79 LanguageType mnOverride
;
81 /** Obtain a language tag string with '-' separator. */
82 OUString
getTagString() const;
84 /** Obtain a locale. */
85 css::lang::Locale
getLocale() const;
87 /** If rStr starts with maLanguageScript ignoring case.
89 We don't have OUString::startsWithIgnoreAsciiCaseAscii()
91 bool startsInIgnoreAsciiCase( std::u16string_view aStr
) const;
94 struct Bcp47CountryEntry
99 const char* mpFallback
;
100 LanguageType mnOverride
;
102 /** Obtain a language tag string with '-' separator. */
103 OUString
getTagString() const;
105 /** Obtain a locale. */
106 css::lang::Locale
getLocale() const;
111 struct IsoLangEngEntry
117 struct IsoLangNoneStdEntry
124 struct IsoLangOtherEntry
127 const char* mpLanguage
;
132 // Entries for languages are lower case, for countries upper case, as
133 // recommended by rfc5646 (obsoletes rfc4646 (obsoletes rfc3066 (obsoletes
134 // rfc1766))). convertIsoNamesToLanguage(), convertLocaleToLanguageImpl()
135 // and lookupFallbackLocale() are case insensitive.
137 // Sort order: Most used first and within one language the default fallback
138 // locale of that language first.
140 // The default entry for a LangID <-> ISO mapping has to be first. For
141 // conversion of legacy mappings one LangID can map to multiple ISO codes
142 // except if the LangID is primary-only, and one ISO code combination can map
143 // to multiple LangIDs.
145 /* Currently (2013-08-29 and 2021-10-24) only these primary LangID are still
146 * used literally in code:
147 * LANGUAGE_ENGLISH LANGUAGE_ARABIC_PRIMARY_ONLY
150 IsoLanguageCountryEntry
const aImplIsoLangEntries
[] =
152 // MS-LANGID codes, ISO639-1/2/3, ISO3166, override
153 { LANGUAGE_ENGLISH_US
, "en", "US", k0
},
154 { LANGUAGE_ENGLISH_UK
, "en", "GB", k0
},
155 { LANGUAGE_ENGLISH
, "en", "" , k0
},
156 { LANGUAGE_ENGLISH_AUS
, "en", "AU", k0
},
157 { LANGUAGE_ENGLISH_CAN
, "en", "CA", k0
},
158 { LANGUAGE_FRENCH
, "fr", "FR", k0
},
159 { LANGUAGE_GERMAN
, "de", "DE", k0
},
160 { LANGUAGE_ITALIAN
, "it", "IT", k0
},
161 { LANGUAGE_DUTCH
, "nl", "NL", k0
},
162 { LANGUAGE_SPANISH_MODERN
, "es", "ES", k0
},
163 { LANGUAGE_PORTUGUESE
, "pt", "PT", k0
},
164 { LANGUAGE_PORTUGUESE_BRAZILIAN
, "pt", "BR", k0
},
165 { LANGUAGE_DANISH
, "da", "DK", k0
},
166 { LANGUAGE_GREEK
, "el", "GR", k0
},
167 { LANGUAGE_CHINESE_SIMPLIFIED
, "zh", "CN", k0
},
168 { LANGUAGE_CHINESE_SIMPLIFIED_LEGACY
, "zh", "CN", k0
},
169 { LANGUAGE_CHINESE_SIMPLIFIED
, "cmn", "CN", kSAME
},
170 { LANGUAGE_CHINESE_TRADITIONAL
, "zh", "TW", k0
},
171 { LANGUAGE_CHINESE_TRADITIONAL
, "cmn", "TW", kSAME
},
172 { LANGUAGE_CHINESE_HONGKONG
, "zh", "HK", k0
},
173 { LANGUAGE_CHINESE_SINGAPORE
, "zh", "SG", k0
},
174 { LANGUAGE_CHINESE_MACAU
, "zh", "MO", k0
},
175 { LANGUAGE_CHINESE_LSO
, "zh", "" , k0
},
176 { LANGUAGE_YUE_CHINESE_HONGKONG
, "yue", "HK", k0
},
177 { LANGUAGE_ENGLISH_HONG_KONG_SAR
, "en", "HK", k0
},
178 { LANGUAGE_JAPANESE
, "ja", "JP", k0
},
179 { LANGUAGE_KOREAN
, "ko", "KR", k0
},
180 { LANGUAGE_KOREAN_JOHAB
, "ko", "KR", k0
},
181 { LANGUAGE_USER_KOREAN_NORTH
, "ko", "KP", k0
},
182 { LANGUAGE_SWEDISH
, "sv", "SE", k0
},
183 { LANGUAGE_SWEDISH_FINLAND
, "sv", "FI", k0
},
184 { LANGUAGE_FINNISH
, "fi", "FI", k0
},
185 { LANGUAGE_RUSSIAN
, "ru", "RU", k0
},
186 { LANGUAGE_TATAR
, "tt", "RU", k0
},
187 { LANGUAGE_ENGLISH_NZ
, "en", "NZ", k0
},
188 { LANGUAGE_ENGLISH_EIRE
, "en", "IE", k0
},
189 { LANGUAGE_DUTCH_BELGIAN
, "nl", "BE", k0
},
190 { LANGUAGE_FRENCH_BELGIAN
, "fr", "BE", k0
},
191 { LANGUAGE_FRENCH_CANADIAN
, "fr", "CA", k0
},
192 { LANGUAGE_FRENCH_SWISS
, "fr", "CH", k0
},
193 { LANGUAGE_GERMAN_SWISS
, "de", "CH", k0
},
194 { LANGUAGE_GERMAN_AUSTRIAN
, "de", "AT", k0
},
195 { LANGUAGE_ITALIAN_SWISS
, "it", "CH", k0
},
196 { LANGUAGE_ALBANIAN
, "sq", "AL", k0
},
197 { LANGUAGE_ARABIC_SAUDI_ARABIA
, "ar", "SA", k0
},
198 { LANGUAGE_ARABIC_EGYPT
, "ar", "EG", k0
},
199 { LANGUAGE_ARABIC_UAE
, "ar", "AE", k0
},
200 { LANGUAGE_ARABIC_IRAQ
, "ar", "IQ", k0
},
201 { LANGUAGE_ARABIC_LIBYA
, "ar", "LY", k0
},
202 { LANGUAGE_ARABIC_ALGERIA
, "ar", "DZ", k0
},
203 { LANGUAGE_ARABIC_MOROCCO
, "ar", "MA", k0
},
204 { LANGUAGE_ARABIC_TUNISIA
, "ar", "TN", k0
},
205 { LANGUAGE_ARABIC_OMAN
, "ar", "OM", k0
},
206 { LANGUAGE_ARABIC_YEMEN
, "ar", "YE", k0
},
207 { LANGUAGE_ARABIC_SYRIA
, "ar", "SY", k0
},
208 { LANGUAGE_ARABIC_JORDAN
, "ar", "JO", k0
},
209 { LANGUAGE_ARABIC_LEBANON
, "ar", "LB", k0
},
210 { LANGUAGE_ARABIC_KUWAIT
, "ar", "KW", k0
},
211 { LANGUAGE_ARABIC_BAHRAIN
, "ar", "BH", k0
},
212 { LANGUAGE_ARABIC_QATAR
, "ar", "QA", k0
},
213 { LANGUAGE_USER_ARABIC_CHAD
, "ar", "TD", k0
},
214 { LANGUAGE_USER_ARABIC_COMOROS
, "ar", "KM", k0
},
215 { LANGUAGE_USER_ARABIC_DJIBOUTI
, "ar", "DJ", k0
},
216 { LANGUAGE_USER_ARABIC_ERITREA
, "ar", "ER", k0
},
217 { LANGUAGE_USER_ARABIC_ISRAEL
, "ar", "IL", k0
},
218 { LANGUAGE_USER_ARABIC_MAURITANIA
, "ar", "MR", k0
},
219 { LANGUAGE_USER_ARABIC_PALESTINE
, "ar", "PS", k0
},
220 { LANGUAGE_USER_ARABIC_SOMALIA
, "ar", "SO", k0
},
221 { LANGUAGE_USER_ARABIC_SUDAN
, "ar", "SD", k0
},
222 { LANGUAGE_ARABIC_PRIMARY_ONLY
, "ar", "" , k0
},
223 { LANGUAGE_BASQUE
, "eu", "ES", k0
},
224 { LANGUAGE_BASQUE
, "eu", "" , kSAME
}, // our earlier definition
225 { LANGUAGE_BULGARIAN
, "bg", "BG", k0
},
226 { LANGUAGE_CZECH
, "cs", "CZ", k0
},
227 { LANGUAGE_CZECH
, "cz", "" , kSAME
},
228 { LANGUAGE_ENGLISH_JAMAICA
, "en", "JM", k0
},
229 { LANGUAGE_ENGLISH_CARIBBEAN
, "en", "BS", k0
}, // not 100%, because AG is Bahamas
230 { LANGUAGE_ENGLISH_BELIZE
, "en", "BZ", k0
},
231 { LANGUAGE_ENGLISH_TRINIDAD
, "en", "TT", k0
},
232 { LANGUAGE_ENGLISH_ZIMBABWE
, "en", "ZW", k0
},
233 { LANGUAGE_ENGLISH_INDONESIA
, "en", "ID", k0
}, // MS reserved
234 { LANGUAGE_ESTONIAN
, "et", "EE", k0
},
235 { LANGUAGE_FAEROESE
, "fo", "FO", k0
},
236 { LANGUAGE_FARSI
, "fa", "IR", k0
},
237 { LANGUAGE_FRENCH_LUXEMBOURG
, "fr", "LU", k0
},
238 { LANGUAGE_FRENCH_MONACO
, "fr", "MC", k0
},
239 { LANGUAGE_GERMAN_LUXEMBOURG
, "de", "LU", k0
},
240 { LANGUAGE_GERMAN_LIECHTENSTEIN
, "de", "LI", k0
},
241 { LANGUAGE_HEBREW
, "he", "IL", k0
}, // new: old was "iw"
242 { LANGUAGE_HEBREW
, "iw", "IL", kSAME
}, // old: new is "he"
243 { LANGUAGE_HUNGARIAN
, "hu", "HU", k0
},
244 { LANGUAGE_ICELANDIC
, "is", "IS", k0
},
245 { LANGUAGE_INDONESIAN
, "id", "ID", k0
}, // new: old was "in"
246 { LANGUAGE_INDONESIAN
, "in", "ID", kSAME
}, // old: new is "id"
247 { LANGUAGE_NORWEGIAN
, "no", "NO", k0
},
248 { LANGUAGE_NORWEGIAN_BOKMAL
, "nb", "NO", k0
},
249 { LANGUAGE_NORWEGIAN_BOKMAL_LSO
, "nb", "" , k0
},
250 { LANGUAGE_NORWEGIAN_NYNORSK
, "nn", "NO", k0
},
251 { LANGUAGE_NORWEGIAN_NYNORSK_LSO
, "nn", "" , k0
},
252 { LANGUAGE_POLISH
, "pl", "PL", k0
},
253 { LANGUAGE_RHAETO_ROMAN
, "rm", "CH", k0
},
254 { LANGUAGE_ROMANIAN
, "ro", "RO", k0
},
255 { LANGUAGE_ROMANIAN_MOLDOVA
, "ro", "MD", k0
},
256 { LANGUAGE_SLOVAK
, "sk", "SK", k0
},
257 { LANGUAGE_SLOVENIAN
, "sl", "SI", k0
},
258 { LANGUAGE_SPANISH_MEXICAN
, "es", "MX", k0
},
259 { LANGUAGE_SPANISH_GUATEMALA
, "es", "GT", k0
},
260 { LANGUAGE_SPANISH_COSTARICA
, "es", "CR", k0
},
261 { LANGUAGE_SPANISH_PANAMA
, "es", "PA", k0
},
262 { LANGUAGE_SPANISH_DOMINICAN_REPUBLIC
, "es", "DO", k0
},
263 { LANGUAGE_SPANISH_VENEZUELA
, "es", "VE", k0
},
264 { LANGUAGE_SPANISH_COLOMBIA
, "es", "CO", k0
},
265 { LANGUAGE_SPANISH_PERU
, "es", "PE", k0
},
266 { LANGUAGE_SPANISH_ARGENTINA
, "es", "AR", k0
},
267 { LANGUAGE_SPANISH_ECUADOR
, "es", "EC", k0
},
268 { LANGUAGE_SPANISH_CHILE
, "es", "CL", k0
},
269 { LANGUAGE_SPANISH_URUGUAY
, "es", "UY", k0
},
270 { LANGUAGE_SPANISH_PARAGUAY
, "es", "PY", k0
},
271 { LANGUAGE_SPANISH_BOLIVIA
, "es", "BO", k0
},
272 { LANGUAGE_SPANISH_EL_SALVADOR
, "es", "SV", k0
},
273 { LANGUAGE_SPANISH_HONDURAS
, "es", "HN", k0
},
274 { LANGUAGE_SPANISH_NICARAGUA
, "es", "NI", k0
},
275 { LANGUAGE_SPANISH_PUERTO_RICO
, "es", "PR", k0
},
276 { LANGUAGE_SPANISH_UNITED_STATES
, "es", "US", k0
},
277 { LANGUAGE_TURKISH
, "tr", "TR", k0
},
278 { LANGUAGE_UKRAINIAN
, "uk", "UA", k0
},
279 { LANGUAGE_VIETNAMESE
, "vi", "VN", k0
},
280 { LANGUAGE_LATVIAN
, "lv", "LV", k0
},
281 { LANGUAGE_MACEDONIAN
, "mk", "MK", k0
},
282 { LANGUAGE_MALAY_MALAYSIA
, "ms", "MY", k0
},
283 { LANGUAGE_MALAY_BRUNEI_DARUSSALAM
, "ms", "BN", k0
},
284 { LANGUAGE_ENGLISH_MALAYSIA
, "en", "MY", k0
},
285 { LANGUAGE_THAI
, "th", "TH", k0
},
286 { LANGUAGE_LITHUANIAN
, "lt", "LT", k0
},
287 { LANGUAGE_LITHUANIAN_CLASSIC
, "lt", "LT", k0
},
288 { LANGUAGE_CROATIAN
, "hr", "HR", k0
}, // Croatian in Croatia
289 { LANGUAGE_CROATIAN_BOSNIA_HERZEGOVINA
, "hr", "BA", k0
},
290 { LANGUAGE_BOSNIAN_LATIN_BOSNIA_HERZEGOVINA
, "bs", "BA", k0
},
291 { LANGUAGE_BOSNIAN_LSO
, "bs", "" , k0
}, // so what is 'bs' vs 'bs-Latn'?
292 { LANGUAGE_SERBIAN_CYRILLIC_SERBIA
, "sr", "RS", k0
}, // Serbian Cyrillic in Serbia
293 { LANGUAGE_OBSOLETE_USER_SERBIAN_CYRILLIC_SERBIA
, "sr", "RS", k0
},
294 { LANGUAGE_SERBIAN_CYRILLIC_SAM
, "sr", "CS", k0
}, // Serbian Cyrillic in Serbia and Montenegro
295 { LANGUAGE_SERBIAN_CYRILLIC_SAM
, "sr", "YU", kSAME
}, // legacy Serbian Cyrillic in Serbia and Montenegro (former Yugoslavia); kludge, sr_CS not supported by ICU 2.6 (3.4 does)
296 { LANGUAGE_SERBIAN_CYRILLIC_MONTENEGRO
, "sr", "ME", k0
},
297 { LANGUAGE_OBSOLETE_USER_SERBIAN_CYRILLIC_MONTENEGRO
, "sr", "ME", k0
},
298 { LANGUAGE_SERBIAN_CYRILLIC_BOSNIA_HERZEGOVINA
, "sr", "BA", k0
},
299 { LANGUAGE_SERBIAN_CYRILLIC_LSO
, "sr", "" , k0
},
300 { LANGUAGE_SERBIAN_LATIN_SERBIA
, "sh", "RS", kSAME
}, // legacy kludge, is sr-Latn-RS now
301 { LANGUAGE_OBSOLETE_USER_SERBIAN_LATIN_SERBIA
, "sh", "RS", kSAME
}, // legacy kludge, is sr-Latn-RS now
302 { LANGUAGE_SERBIAN_LATIN_SAM
, "sh", "CS", kSAME
}, // legacy kludge, is sr-Latn-CS now
303 { LANGUAGE_SERBIAN_LATIN_SAM
, "sh", "YU", kSAME
}, // legacy kludge, is sr-Latn-YU now
304 { LANGUAGE_SERBIAN_LATIN_MONTENEGRO
, "sh", "ME", kSAME
}, // legacy kludge, is sr-Latn-ME now
305 { LANGUAGE_OBSOLETE_USER_SERBIAN_LATIN_MONTENEGRO
, "sh", "ME", kSAME
}, // legacy kludge, is sr-Latn-ME now
306 { LANGUAGE_SERBIAN_LATIN_BOSNIA_HERZEGOVINA
, "sh", "BA", kSAME
}, // legacy kludge, is sr-Latn-BA now
307 { LANGUAGE_SERBIAN_LATIN_LSO
, "sh", "" , kSAME
}, // legacy kludge, is sr-Latn now
308 { LANGUAGE_ARMENIAN
, "hy", "AM", k0
},
309 { LANGUAGE_USER_ARMENIAN_RUSSIA
, "hy", "RU", k0
},
310 { LANGUAGE_USER_ARMENIAN_IRAN
, "hy", "IR", k0
},
311 { LANGUAGE_AZERI_LATIN
, "az", "AZ", k0
}, // macrolanguage code
312 { LANGUAGE_UZBEK_LATIN
, "uz", "UZ", k0
}, // macrolanguage code
313 { LANGUAGE_UZBEK_LATIN_LSO
, "uz", "" , k0
}, // macrolanguage code
314 { LANGUAGE_BENGALI_BANGLADESH
, "bn", "BD", k0
},
315 { LANGUAGE_BENGALI
, "bn", "IN", k0
},
316 { LANGUAGE_BURMESE
, "my", "MM", k0
},
317 { LANGUAGE_KAZAKH
, "kk", "KZ", k0
},
318 { LANGUAGE_ENGLISH_INDIA
, "en", "IN", k0
},
319 { LANGUAGE_URDU_INDIA
, "ur", "IN", k0
},
320 { LANGUAGE_URDU_PAKISTAN
, "ur", "PK", k0
},
321 { LANGUAGE_HINDI
, "hi", "IN", k0
},
322 { LANGUAGE_GUJARATI
, "gu", "IN", k0
},
323 { LANGUAGE_KANNADA
, "kn", "IN", k0
},
324 { LANGUAGE_ASSAMESE
, "as", "IN", k0
},
325 { LANGUAGE_KASHMIRI_INDIA
, "ks", "IN", kSAME
},
326 { LANGUAGE_KASHMIRI
, "ks", "" , kSAME
}, // Kashmiri in "Jammu and Kashmir" ... no ISO3166 code for that
327 { LANGUAGE_MALAYALAM
, "ml", "IN", k0
},
328 { LANGUAGE_MANIPURI
, "mni", "IN", k0
}, // MS reserved
329 { LANGUAGE_MARATHI
, "mr", "IN", k0
},
330 { LANGUAGE_KONKANI
, "kok", "IN", k0
},
331 { LANGUAGE_NEPALI
, "ne", "NP", k0
},
332 { LANGUAGE_NEPALI_INDIA
, "ne", "IN", k0
},
333 { LANGUAGE_ODIA
, "or", "IN", k0
},
334 { LANGUAGE_PUNJABI
, "pa", "IN", k0
},
335 { LANGUAGE_SANSKRIT
, "sa", "IN", k0
},
336 { LANGUAGE_TAMIL
, "ta", "IN", k0
},
337 { LANGUAGE_TAMIL_SRI_LANKA
, "ta", "LK", k0
},
338 { LANGUAGE_TELUGU
, "te", "IN", k0
},
339 { LANGUAGE_PUNJABI_PAKISTAN
, "pnb", "PK", k0
},
340 { LANGUAGE_PUNJABI_ARABIC_LSO
, "pnb", "" , k0
},
341 { LANGUAGE_PUNJABI_PAKISTAN
, "lah", "PK", kSAME
}, // macrolanguage code, earlier preferred 'lah' over 'pa' for Western Panjabi, now there is 'pnb'
342 { LANGUAGE_PUNJABI_PAKISTAN
, "pa", "PK", kSAME
}, // MS maps this to 'pa-Arab-PK', but 'pa'='pan' Eastern Panjabi is not used in PK, only in
343 { LANGUAGE_SINDHI_PAKISTAN
, "sd", "PK", kSAME
}, // Arabic script
344 { LANGUAGE_SINDHI
, "sd", "IN", kSAME
}, // Devanagari script
345 { LANGUAGE_BELARUSIAN
, "be", "BY", k0
},
346 { LANGUAGE_CATALAN
, "ca", "ES", k0
}, // Spain (default)
347 { LANGUAGE_USER_CATALAN_ANDORRA
, "ca", "AD", k0
},
348 { LANGUAGE_USER_CATALAN_FRANCE
, "ca", "FR", k0
},
349 { LANGUAGE_USER_CATALAN_ITALY
, "ca", "IT", k0
},
350 //LANGUAGE_CATALAN_VALENCIAN ca-ES-valencia Bcp47CountryEntry takes precedence
351 { LANGUAGE_CATALAN_VALENCIAN
, "ca", "XV", kSAME
}, // XV: ISO 3166 user-assigned; old workaround for UI localization only, in case it escaped to document content
352 { LANGUAGE_CATALAN_VALENCIAN
, "qcv", "ES", kSAME
}, // qcv: ISO 639-3 reserved-for-local-use; old UI localization quirk only, in case it escaped to document content
353 { LANGUAGE_FRENCH_CAMEROON
, "fr", "CM", k0
},
354 { LANGUAGE_FRENCH_COTE_D_IVOIRE
, "fr", "CI", k0
},
355 { LANGUAGE_FRENCH_MALI
, "fr", "ML", k0
},
356 { LANGUAGE_FRENCH_SENEGAL
, "fr", "SN", k0
},
357 { LANGUAGE_FRENCH_ZAIRE
, "fr", "CD", k0
}, // Democratic Republic Of Congo
358 { LANGUAGE_FRENCH_MOROCCO
, "fr", "MA", k0
},
359 { LANGUAGE_FRENCH_REUNION
, "fr", "RE", k0
},
360 { LANGUAGE_FRISIAN_NETHERLANDS
, "fy", "NL", k0
},
361 { LANGUAGE_GAELIC_IRELAND
, "ga", "IE", k0
},
362 { LANGUAGE_GAELIC_SCOTLAND
, "gd", "GB", k0
},
363 { LANGUAGE_GAELIC_SCOTLAND_LEGACY
, "gd", "GB", k0
},
364 { LANGUAGE_GALICIAN
, "gl", "ES", k0
},
365 { LANGUAGE_GEORGIAN
, "ka", "GE", k0
},
366 { LANGUAGE_KHMER
, "km", "KH", k0
},
367 { LANGUAGE_KIRGHIZ
, "ky", "KG", k0
},
368 { LANGUAGE_LAO
, "lo", "LA", k0
},
369 { LANGUAGE_MALTESE
, "mt", "MT", k0
},
370 { LANGUAGE_MONGOLIAN_CYRILLIC_MONGOLIA
, "mn", "MN", k0
}, // macrolanguage code; should be khk-MN; Cyrillic script
371 { LANGUAGE_MONGOLIAN_CYRILLIC_LSO
, "mn", "" , k0
}, // macrolanguage code; should be khk; Cyrillic script
372 { LANGUAGE_ROMANIAN_MOLDOVA
, "ro", "MD", k0
},
373 { LANGUAGE_ROMANIAN_MOLDOVA
, "mo", "MD", k0
}, // mo-MD was associated with Russian Moldova LCID, apparently an error; 'mo' is retired, merged with 'ro', see http://www-01.sil.org/iso639-3/documentation.asp?id=mol
374 { LANGUAGE_RUSSIAN_MOLDOVA
, "ru", "MD", k0
}, // as per [MS-LCID] rev. 7.0 2015-06-30
375 { LANGUAGE_SWAHILI
, "sw", "KE", k0
},
376 { LANGUAGE_USER_SWAHILI_TANZANIA
, "sw", "TZ", k0
},
377 { LANGUAGE_TAJIK
, "tg", "TJ", k0
},
378 { LANGUAGE_TAJIK_LSO
, "tg", "" , k0
},
379 { LANGUAGE_TIBETAN
, "bo", "CN", k0
}, // CN politically correct?
380 { LANGUAGE_USER_TIBETAN_INDIA
, "bo", "IN", k0
},
381 { LANGUAGE_USER_TIBETAN_BHUTAN
, "bo", "BT", k0
},
382 { LANGUAGE_DZONGKHA_BHUTAN
, "dz", "BT", k0
},
383 { LANGUAGE_TIBETAN_BHUTAN
, "dz", "BT", k0
}, // MS reserved for bo-BT, but LCID was used as Dzongkha, see #i53497#
384 { LANGUAGE_USER_DZONGKHA_MAP_LONLY
, "dz", "" , k0
}, // because of the MS error, see lang.h
385 { LANGUAGE_TURKMEN
, "tk", "TM", k0
},
386 { LANGUAGE_WELSH
, "cy", "GB", k0
},
387 { LANGUAGE_SESOTHO
, "st", "ZA", k0
},
388 { LANGUAGE_SEPEDI
, "nso", "ZA", k0
},
389 { LANGUAGE_SEPEDI
, "ns", "ZA", kSAME
}, // fake "ns" for compatibility with existing OOo1.1.x localization to be able to read those documents
390 { LANGUAGE_TSONGA
, "ts", "ZA", k0
},
391 { LANGUAGE_TSWANA
, "tn", "ZA", k0
},
392 { LANGUAGE_ENGLISH_SAFRICA
, "en", "ZA", k0
},
393 { LANGUAGE_AFRIKAANS
, "af", "ZA", k0
},
394 { LANGUAGE_VENDA
, "ve", "ZA", k0
}, // default 639-1
395 { LANGUAGE_VENDA
, "ven", "ZA", kSAME
}, // 639-2 may have been used temporarily since 2004-07-23
396 { LANGUAGE_XHOSA
, "xh", "ZA", k0
},
397 { LANGUAGE_ZULU
, "zu", "ZA", k0
},
398 // { LANGUAGE_QUECHUA_COLOMBIA, "quc", "CO", k0 }, // MS reserved, and looks wrong, quc would be in Guatemala, not Colombia
399 { LANGUAGE_QUECHUA_ECUADOR
, "quz", "EC", k0
}, // MS
400 { LANGUAGE_QUECHUA_ECUADOR
, "qu", "EC", kSAME
}, // macrolanguage code
401 { LANGUAGE_QUECHUA_PERU
, "quz", "PE", k0
}, // MS
402 { LANGUAGE_QUECHUA_PERU
, "qu", "PE", kSAME
}, // macrolanguage code
403 { LANGUAGE_QUECHUA_BOLIVIA
, "qu", "BO", k0
}, // macrolanguage code, TODO instead: quh-BO or qul-BO; MS says quz-BO which is wrong
404 { LANGUAGE_PASHTO
, "ps", "AF", k0
},
405 { LANGUAGE_OROMO
, "om", "ET", k0
},
406 { LANGUAGE_DHIVEHI
, "dv", "MV", k0
},
407 { LANGUAGE_UIGHUR_CHINA
, "ug", "CN", k0
},
408 { LANGUAGE_TIGRIGNA_ETHIOPIA
, "ti", "ET", k0
},
409 { LANGUAGE_TIGRIGNA_ERITREA
, "ti", "ER", k0
},
410 { LANGUAGE_AMHARIC_ETHIOPIA
, "am", "ET", k0
},
411 { LANGUAGE_GUARANI_PARAGUAY
, "gug", "PY", k0
},
412 { LANGUAGE_HAWAIIAN_UNITED_STATES
, "haw", "US", k0
},
413 { LANGUAGE_EDO
, "bin", "NG", k0
}, // MS reserved
414 { LANGUAGE_FULFULDE_NIGERIA
, "ff", "NG", k0
}, // macrolanguage code; MS since rev.15
415 { LANGUAGE_FULFULDE_NIGERIA
, "fuv", "NG", kSAME
}, // MS reserved until rev.15, since rev.15 "ff-NG" and "ff-Latn-NG"
416 { LANGUAGE_FULFULDE_SENEGAL
, "ff", "SN", k0
}, // macrolanguage code
417 { LANGUAGE_HAUSA_NIGERIA
, "ha", "NG", kSAME
},
418 { LANGUAGE_USER_HAUSA_GHANA
, "ha", "GH", kSAME
},
419 { LANGUAGE_IGBO_NIGERIA
, "ig", "NG", k0
},
420 { LANGUAGE_KANURI_NIGERIA
, "kr", "NG", k0
}, // macrolanguage code; MS reserved until rev.15
421 { LANGUAGE_YORUBA
, "yo", "NG", k0
},
422 { LANGUAGE_SOMALI
, "so", "SO", k0
},
423 { LANGUAGE_PAPIAMENTU
, "pap", "AN", k0
},
424 { LANGUAGE_USER_PAPIAMENTU_ARUBA
, "pap", "AW", k0
},
425 { LANGUAGE_USER_PAPIAMENTU_CURACAO
, "pap", "CW", k0
},
426 { LANGUAGE_USER_PAPIAMENTU_BONAIRE
, "pap", "BQ", k0
},
427 { LANGUAGE_ENGLISH_SINGAPORE
, "en", "SG", k0
},
428 { LANGUAGE_USER_YIDDISH_US
, "yi", "US", k0
},
429 { LANGUAGE_USER_YIDDISH_ISRAEL
, "yi", "IL", k0
}, // new: old was "ji"
430 { LANGUAGE_USER_YIDDISH_ISRAEL
, "ji", "IL", kSAME
}, // old: new is "yi"
431 { LANGUAGE_SYRIAC
, "syr", "TR", k0
}, // "TR" according to http://www.ethnologue.com/show_language.asp?code=SYC
432 { LANGUAGE_SINHALESE_SRI_LANKA
, "si", "LK", k0
},
433 { LANGUAGE_CHEROKEE_UNITED_STATES
, "chr", "US", kSAME
},
434 { LANGUAGE_INUKTITUT_LATIN_CANADA
, "iu", "CA", kSAME
}, // macrolanguage code
435 { LANGUAGE_INUKTITUT_LATIN_LSO
, "iu", "" , kSAME
}, // macrolanguage code
436 { LANGUAGE_SAMI_NORTHERN_NORWAY
, "se", "NO", k0
},
437 { LANGUAGE_SAMI_INARI
, "smn", "FI", k0
},
438 { LANGUAGE_SAMI_INARI_LSO
, "smn", "" , k0
},
439 { LANGUAGE_SAMI_LULE_NORWAY
, "smj", "NO", k0
},
440 { LANGUAGE_SAMI_LULE_SWEDEN
, "smj", "SE", k0
},
441 { LANGUAGE_SAMI_LULE_LSO
, "smj", "" , k0
},
442 { LANGUAGE_SAMI_NORTHERN_FINLAND
, "se", "FI", k0
},
443 { LANGUAGE_SAMI_NORTHERN_SWEDEN
, "se", "SE", k0
},
444 { LANGUAGE_SAMI_SKOLT
, "sms", "FI", k0
},
445 { LANGUAGE_SAMI_SKOLT_LSO
, "sms", "" , k0
},
446 { LANGUAGE_SAMI_SOUTHERN_NORWAY
, "sma", "NO", k0
},
447 { LANGUAGE_SAMI_SOUTHERN_SWEDEN
, "sma", "SE", k0
},
448 { LANGUAGE_SAMI_SOUTHERN_LSO
, "sma", "" , k0
},
449 { LANGUAGE_USER_SAMI_KILDIN_RUSSIA
, "sjd", "RU", k0
},
450 { LANGUAGE_MAPUDUNGUN_CHILE
, "arn", "CL", k0
},
451 { LANGUAGE_CORSICAN_FRANCE
, "co", "FR", k0
},
452 { LANGUAGE_ALSATIAN_FRANCE
, "gsw", "FR", k0
}, // 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.
453 { LANGUAGE_YAKUT_RUSSIA
, "sah", "RU", k0
},
454 { LANGUAGE_MOHAWK_CANADA
, "moh", "CA", k0
},
455 { LANGUAGE_BASHKIR_RUSSIA
, "ba", "RU", k0
},
456 { LANGUAGE_KICHE_GUATEMALA
, "qut", "GT", k0
}, // MS reserved since rev.15
457 { LANGUAGE_DARI_AFGHANISTAN
, "prs", "AF", k0
},
458 { LANGUAGE_DARI_AFGHANISTAN
, "gbz", "AF", kSAME
}, // was an error
459 { LANGUAGE_WOLOF_SENEGAL
, "wo", "SN", k0
},
460 { LANGUAGE_FILIPINO
, "fil", "PH", k0
},
461 { LANGUAGE_USER_TAGALOG
, "tl", "PH", k0
},
462 { LANGUAGE_ENGLISH_PHILIPPINES
, "en", "PH", k0
},
463 { LANGUAGE_IBIBIO_NIGERIA
, "ibb", "NG", k0
}, // MS reserved
464 { LANGUAGE_YI
, "ii", "CN", k0
},
465 { LANGUAGE_ENGLISH_ARAB_EMIRATES
, "en", "AE", k0
},
466 { LANGUAGE_ENGLISH_BAHRAIN
, "en", "BH", k0
}, // MS reserved
467 { LANGUAGE_ENGLISH_EGYPT
, "en", "EG", k0
}, // MS reserved
468 { LANGUAGE_ENGLISH_JORDAN
, "en", "JO", k0
}, // MS reserved
469 { LANGUAGE_ENGLISH_KUWAIT
, "en", "KW", k0
}, // MS reserved
470 { LANGUAGE_ENGLISH_TURKEY
, "en", "TR", k0
}, // MS reserved
471 { LANGUAGE_ENGLISH_YEMEN
, "en", "YE", k0
}, // MS reserved
472 { LANGUAGE_TAMAZIGHT_LATIN_ALGERIA
, "kab", "DZ", k0
}, // In practice Kabyle is the language used for this
473 { LANGUAGE_OBSOLETE_USER_KABYLE
, "kab", "DZ", k0
},
474 { LANGUAGE_TAMAZIGHT_LATIN_ALGERIA
, "ber", "DZ", kSAME
}, // In practice Algeria has standardized on Kabyle as the member of the "ber" collective which gets used there.
475 { LANGUAGE_TAMAZIGHT_TIFINAGH_MOROCCO
, "tmz", "MA", kSAME
},
476 { LANGUAGE_TAMAZIGHT_MOROCCO
, "tmz", "MA", k0
}, // MS reserved
477 { LANGUAGE_TAMAZIGHT_TIFINAGH_MOROCCO
, "ber", "MA", kSAME
}, // Morocco is officially using Tifinagh for its Berber languages, old kludge to distinguish from LANGUAGE_TAMAZIGHT_LATIN_ALGERIA
478 { LANGUAGE_LATIN
, "la", "VA", k0
},
479 { LANGUAGE_OBSOLETE_USER_LATIN_VATICAN
, "la", "VA", LANGUAGE_LATIN
},
480 { LANGUAGE_OBSOLETE_USER_LATIN
, "la", "VA", LANGUAGE_LATIN
},
481 { LANGUAGE_LATIN
, "la", "" , kSAME
},
482 { LANGUAGE_USER_ESPERANTO
, "eo", "" , k0
},
483 { LANGUAGE_USER_INTERLINGUA
, "ia", "" , k0
},
484 { LANGUAGE_USER_INTERLINGUE
, "ie", "" , k0
},
485 { LANGUAGE_MAORI_NEW_ZEALAND
, "mi", "NZ", k0
},
486 { LANGUAGE_OBSOLETE_USER_MAORI
, "mi", "NZ", k0
},
487 { LANGUAGE_KINYARWANDA_RWANDA
, "rw", "RW", k0
},
488 { LANGUAGE_OBSOLETE_USER_KINYARWANDA
, "rw", "RW", k0
},
489 { LANGUAGE_UPPER_SORBIAN_GERMANY
, "hsb", "DE", k0
}, // 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
490 { LANGUAGE_OBSOLETE_USER_UPPER_SORBIAN
,"hsb", "DE", k0
},
491 { LANGUAGE_LOWER_SORBIAN_GERMANY
, "dsb", "DE", k0
}, // 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
492 { LANGUAGE_LOWER_SORBIAN_LSO
, "dsb", "" , k0
},
493 { LANGUAGE_OBSOLETE_USER_LOWER_SORBIAN
,"dsb", "DE", k0
},
494 { LANGUAGE_OCCITAN_FRANCE
, "oc", "FR", kSAME
},
495 { LANGUAGE_OBSOLETE_USER_OCCITAN
, "oc", "FR", LANGUAGE_OCCITAN_FRANCE
},
496 { LANGUAGE_USER_KURDISH_TURKEY
, "kmr", "TR", kSAME
},
497 { LANGUAGE_USER_KURDISH_TURKEY
, "ku", "TR", kSAME
},
498 { LANGUAGE_USER_KURDISH_SYRIA
, "kmr", "SY", kSAME
},
499 { LANGUAGE_USER_KURDISH_SYRIA
, "ku", "SY", kSAME
},
500 { LANGUAGE_KURDISH_ARABIC_IRAQ
, "ckb", "IQ", k0
},
501 { LANGUAGE_KURDISH_ARABIC_IRAQ
, "ku", "IQ", kSAME
},
502 { LANGUAGE_OBSOLETE_USER_KURDISH_IRAQ
, "ku", "IQ", LANGUAGE_KURDISH_ARABIC_IRAQ
},
503 { LANGUAGE_USER_KURDISH_SOUTHERN_IRAN
, "sdh", "IR", k0
},
504 { LANGUAGE_USER_KURDISH_SOUTHERN_IRAQ
, "sdh", "IQ", k0
},
505 { LANGUAGE_USER_KURDISH_IRAN
, "ckb", "IR", k0
},
506 { LANGUAGE_USER_KURDISH_IRAN
, "ku", "IR", kSAME
},
507 { LANGUAGE_KURDISH_ARABIC_LSO
, "ckb", "" , k0
},
508 { LANGUAGE_USER_SARDINIAN
, "sc", "IT", k0
}, // macrolanguage code
509 { LANGUAGE_USER_SARDINIAN_CAMPIDANESE
, "sro", "IT", k0
},
510 { LANGUAGE_USER_SARDINIAN_GALLURESE
, "sdn", "IT", k0
},
511 { LANGUAGE_USER_SARDINIAN_LOGUDORESE
, "src", "IT", k0
},
512 { LANGUAGE_USER_SARDINIAN_SASSARESE
, "sdc", "IT", k0
},
513 { LANGUAGE_BRETON_FRANCE
, "br", "FR", k0
},
514 { LANGUAGE_OBSOLETE_USER_BRETON
, "br", "FR", k0
},
515 { LANGUAGE_KALAALLISUT_GREENLAND
, "kl", "GL", k0
},
516 { LANGUAGE_OBSOLETE_USER_KALAALLISUT
, "kl", "GL", k0
},
517 { LANGUAGE_USER_SWAZI
, "ss", "ZA", k0
},
518 { LANGUAGE_USER_NDEBELE_SOUTH
, "nr", "ZA", k0
},
519 { LANGUAGE_TSWANA_BOTSWANA
, "tn", "BW", k0
},
520 { LANGUAGE_OBSOLETE_USER_TSWANA_BOTSWANA
, "tn", "BW", k0
},
521 { LANGUAGE_USER_ENGLISH_BOTSWANA
, "en", "BW", k0
},
522 { LANGUAGE_USER_MOORE
, "mos", "BF", k0
},
523 { LANGUAGE_USER_BAMBARA
, "bm", "ML", k0
},
524 { LANGUAGE_USER_AKAN
, "ak", "GH", k0
},
525 { LANGUAGE_LUXEMBOURGISH_LUXEMBOURG
, "lb", "LU", k0
},
526 { LANGUAGE_OBSOLETE_USER_LUXEMBOURGISH
, "lb", "LU", k0
},
527 { LANGUAGE_USER_FRIULIAN
, "fur", "IT", k0
},
528 { LANGUAGE_USER_FIJIAN
, "fj", "FJ", k0
},
529 { LANGUAGE_USER_AFRIKAANS_NAMIBIA
, "af", "NA", k0
},
530 { LANGUAGE_USER_ENGLISH_NAMIBIA
, "en", "NA", k0
},
531 { LANGUAGE_USER_WALLOON
, "wa", "BE", k0
},
532 { LANGUAGE_USER_COPTIC
, "cop", "EG", k0
},
533 { LANGUAGE_USER_GASCON
, "gsc", "FR", k0
},
534 { LANGUAGE_USER_GERMAN_BELGIUM
, "de", "BE", k0
},
535 { LANGUAGE_USER_CHUVASH
, "cv", "RU", k0
},
536 { LANGUAGE_USER_EWE_GHANA
, "ee", "GH", k0
},
537 { LANGUAGE_USER_ENGLISH_GHANA
, "en", "GH", k0
},
538 { LANGUAGE_USER_SANGO
, "sg", "CF", k0
},
539 { LANGUAGE_USER_GANDA
, "lg", "UG", k0
},
540 { LANGUAGE_USER_LINGALA_DRCONGO
, "ln", "CD", k0
},
541 { LANGUAGE_USER_LOW_GERMAN
, "nds", "DE", k0
},
542 { LANGUAGE_USER_HILIGAYNON
, "hil", "PH", k0
},
543 { LANGUAGE_USER_ENGLISH_MALAWI
, "en", "MW", k0
}, /* en default for MW */
544 { LANGUAGE_USER_NYANJA
, "ny", "MW", k0
},
545 { LANGUAGE_USER_KASHUBIAN
, "csb", "PL", k0
},
546 { LANGUAGE_SPANISH_CUBA
, "es", "CU", k0
},
547 { LANGUAGE_OBSOLETE_USER_SPANISH_CUBA
, "es", "CU", k0
},
548 { LANGUAGE_USER_QUECHUA_NORTH_BOLIVIA
, "qul", "BO", k0
},
549 { LANGUAGE_USER_QUECHUA_SOUTH_BOLIVIA
, "quh", "BO", k0
},
550 { LANGUAGE_USER_BODO_INDIA
, "brx", "IN", k0
},
551 { LANGUAGE_USER_DOGRI_INDIA
, "dgo", "IN", k0
},
552 { LANGUAGE_USER_MAITHILI_INDIA
, "mai", "IN", k0
},
553 { LANGUAGE_USER_SANTALI_INDIA
, "sat", "IN", k0
},
554 { LANGUAGE_USER_TETUN
, "tet", "ID", k0
},
555 { LANGUAGE_USER_TETUN_TIMOR_LESTE
, "tet", "TL", k0
},
556 { LANGUAGE_USER_TOK_PISIN
, "tpi", "PG", k0
},
557 { LANGUAGE_USER_SHUSWAP
, "shs", "CA", k0
},
558 { LANGUAGE_USER_ANCIENT_GREEK
, "grc", "GR", k0
},
559 { LANGUAGE_USER_ASTURIAN
, "ast", "ES", k0
},
560 { LANGUAGE_USER_LATGALIAN
, "ltg", "LV", k0
},
561 { LANGUAGE_USER_MAORE
, "swb", "YT", k0
},
562 { LANGUAGE_USER_BUSHI
, "buc", "YT", k0
},
563 { LANGUAGE_USER_TAHITIAN
, "ty", "PF", k0
},
564 { LANGUAGE_MALAGASY_PLATEAU
, "plt", "MG", k0
}, // MS reserved
565 { LANGUAGE_MALAGASY_PLATEAU
, "mg", "MG", kSAME
},
566 { LANGUAGE_OBSOLETE_USER_MALAGASY_PLATEAU
, "plt", "MG", k0
},
567 { LANGUAGE_USER_BAFIA
, "ksf", "CM", k0
},
568 { LANGUAGE_USER_GIKUYU
, "ki", "KE", k0
},
569 { LANGUAGE_USER_RUSYN_UKRAINE
, "rue", "UA", k0
},
570 { LANGUAGE_USER_RUSYN_SLOVAKIA
, "rue", "SK", k0
},
571 { LANGUAGE_USER_LIMBU
, "lif", "NP", k0
},
572 { LANGUAGE_USER_LOJBAN
, "jbo", "" , k0
},
573 { LANGUAGE_USER_HAITIAN
, "ht", "HT", k0
},
574 { LANGUAGE_FRENCH_HAITI
, "fr", "HT", k0
},
575 { LANGUAGE_USER_BEEMBE
, "beq", "CG", k0
},
576 { LANGUAGE_USER_BEKWEL
, "bkw", "CG", k0
},
577 { LANGUAGE_USER_KITUBA
, "mkw", "CG", k0
},
578 { LANGUAGE_USER_LARI
, "ldi", "CG", k0
},
579 { LANGUAGE_USER_MBOCHI
, "mdw", "CG", k0
},
580 { LANGUAGE_USER_TEKE_EBOO
, "ebo", "CG", k0
},
581 { LANGUAGE_USER_TEKE_IBALI
, "tek", "CG", k0
},
582 { LANGUAGE_USER_TEKE_TYEE
, "tyx", "CG", k0
},
583 { LANGUAGE_USER_VILI
, "vif", "CG", k0
},
584 { LANGUAGE_USER_PORTUGUESE_ANGOLA
, "pt", "AO", k0
},
585 { LANGUAGE_USER_MANX
, "gv", "GB", k0
},
586 { LANGUAGE_USER_ARAGONESE
, "an", "ES", k0
},
587 { LANGUAGE_USER_KEYID
, "qtz", "" , k0
}, // key id pseudolanguage used for UI testing
588 { LANGUAGE_USER_PALI_LATIN
, "pli", "" , kSAME
}, // Pali with Latin script, ISO 639-3 (sigh..) back-compat, Latin is not a default script though...
589 { LANGUAGE_USER_KYRGYZ_CHINA
, "ky", "CN", k0
},
590 { LANGUAGE_USER_KOMI_ZYRIAN
, "kpv", "RU", k0
},
591 { LANGUAGE_USER_KOMI_PERMYAK
, "koi", "RU", k0
},
592 { LANGUAGE_USER_PITJANTJATJARA
, "pjt", "AU", k0
},
593 { LANGUAGE_USER_ERZYA
, "myv", "RU", k0
},
594 { LANGUAGE_USER_MARI_MEADOW
, "mhr", "RU", k0
},
595 { LANGUAGE_USER_KHANTY
, "kca", "RU", k0
},
596 { LANGUAGE_USER_LIVONIAN
, "liv", "RU", k0
},
597 { LANGUAGE_USER_MOKSHA
, "mdf", "RU", k0
},
598 { LANGUAGE_USER_MARI_HILL
, "mrj", "RU", k0
},
599 { LANGUAGE_USER_NGANASAN
, "nio", "RU", k0
},
600 { LANGUAGE_USER_OLONETS
, "olo", "RU", k0
},
601 { LANGUAGE_USER_VEPS
, "vep", "RU", k0
},
602 { LANGUAGE_USER_VORO
, "vro", "EE", k0
},
603 { LANGUAGE_USER_NENETS
, "yrk", "RU", k0
},
604 { LANGUAGE_USER_AKA
, "axk", "CF", k0
},
605 { LANGUAGE_USER_AKA_CONGO
, "axk", "CG", k0
},
606 { LANGUAGE_USER_DIBOLE
, "bvx", "CG", k0
},
607 { LANGUAGE_USER_DOONDO
, "dde", "CG", k0
},
608 { LANGUAGE_USER_KAAMBA
, "xku", "CG", k0
},
609 { LANGUAGE_USER_KOONGO
, "kng", "CD", k0
},
610 { LANGUAGE_USER_KOONGO_CONGO
, "kng", "CG", k0
},
611 { LANGUAGE_USER_KUNYI
, "njx", "CG", k0
},
612 { LANGUAGE_USER_NGUNGWEL
, "ngz", "CG", k0
},
613 { LANGUAGE_USER_NJYEM
, "njy", "CM", k0
},
614 { LANGUAGE_USER_NJYEM_CONGO
, "njy", "CG", k0
},
615 { LANGUAGE_USER_PUNU
, "puu", "GA", k0
},
616 { LANGUAGE_USER_PUNU_CONGO
, "puu", "CG", k0
},
617 { LANGUAGE_USER_SUUNDI
, "sdj", "CG", k0
},
618 { LANGUAGE_USER_TEKE_KUKUYA
, "kkw", "CG", k0
},
619 { LANGUAGE_USER_TSAANGI
, "tsa", "CG", k0
},
620 { LANGUAGE_USER_YAKA
, "iyx", "CG", k0
},
621 { LANGUAGE_USER_YOMBE
, "yom", "CD", k0
},
622 { LANGUAGE_USER_YOMBE_CONGO
, "yom", "CG", k0
},
623 { LANGUAGE_USER_SIDAMA
, "sid", "ET", k0
},
624 { LANGUAGE_USER_NKO
, "nqo", "GN", k0
},
625 { LANGUAGE_USER_UDMURT
, "udm", "RU", k0
},
626 { LANGUAGE_USER_CORNISH
, "kw", "GB", k0
},
627 { LANGUAGE_USER_CORNISH
, "kw", "UK", kSAME
}, // old erroneous tag
628 { LANGUAGE_USER_SAMI_PITE_SWEDEN
, "sje", "SE", k0
},
629 { LANGUAGE_USER_NGAEBERE
, "gym", "PA", k0
},
630 { LANGUAGE_USER_KUMYK
, "kum", "RU", k0
},
631 { LANGUAGE_USER_NOGAI
, "nog", "RU", k0
},
632 { LANGUAGE_USER_LADIN
, "lld", "IT", k0
},
633 { LANGUAGE_USER_FRENCH_BURKINA_FASO
, "fr", "BF", k0
},
634 { LANGUAGE_USER_PUINAVE
, "pui", "CO", k0
},
635 { LANGUAGE_USER_AVAR
, "av", "RU", k0
},
636 { LANGUAGE_USER_LENGO
, "lgr", "SB", k0
},
637 { LANGUAGE_USER_FRENCH_BENIN
, "fr", "BJ", k0
},
638 { LANGUAGE_USER_FRENCH_NIGER
, "fr", "NE", k0
},
639 { LANGUAGE_USER_FRENCH_TOGO
, "fr", "TG", k0
},
640 { LANGUAGE_USER_KVEN_FINNISH
, "fkv", "NO", k0
},
641 { LANGUAGE_USER_CHURCH_SLAVIC
, "cu", "RU", k0
},
642 { LANGUAGE_USER_VENETIAN
, "vec", "IT", k0
},
643 { LANGUAGE_USER_ENGLISH_GAMBIA
, "en", "GM", k0
},
644 { LANGUAGE_USER_OCCITAN_ARANESE
, "oc", "ES", kSAME
},
645 { LANGUAGE_USER_ARPITAN_FRANCE
, "frp", "FR", k0
},
646 { LANGUAGE_USER_ARPITAN_ITALY
, "frp", "IT", k0
},
647 { LANGUAGE_USER_ARPITAN_SWITZERLAND
, "frp", "CH", k0
},
648 { LANGUAGE_USER_APATANI
, "apt", "IN", k0
},
649 { LANGUAGE_USER_ENGLISH_MAURITIUS
, "en", "MU", k0
},
650 { LANGUAGE_USER_FRENCH_MAURITIUS
, "fr", "MU", k0
},
651 { LANGUAGE_USER_SILESIAN
, "szl", "PL", k0
},
652 { LANGUAGE_USER_MANCHU
, "mnc", "CN", k0
},
653 { LANGUAGE_USER_XIBE
, "sjo", "CN", k0
},
654 { LANGUAGE_USER_KITUBA_DRCONGO
, "ktu", "CD", k0
},
655 { LANGUAGE_USER_FON
, "fon", "BJ", k0
},
656 { LANGUAGE_USER_PLAUTDIETSCH
, "pdt", "CA", k0
},
657 { LANGUAGE_USER_ARMENIAN_WESTERN
, "hyw", "AM", k0
},
658 { LANGUAGE_USER_ARMENIAN_CLASSICAL
, "xcl", "AM", k0
},
659 { LANGUAGE_USER_JUHOAN
, "ktz", "NA", k0
},
660 { LANGUAGE_USER_NARO
, "nhr", "BW", k0
},
661 { LANGUAGE_USER_ILOKO
, "ilo", "PH", k0
},
662 { LANGUAGE_USER_ENGLISH_ZAMBIA
, "en", "ZM", k0
},
663 { LANGUAGE_USER_ENGLISH_SRI_LANKA
, "en", "LK", k0
},
664 { LANGUAGE_USER_ENGLISH_NIGERIA
, "en", "NG", k0
},
665 { LANGUAGE_USER_KABARDIAN
, "kbd", "RU", k0
}, // Cyrillic script
666 { LANGUAGE_USER_GUADELOUPEAN_CREOLE_FRENCH
, "gcf", "GP", k0
},
667 { LANGUAGE_USER_LIGURIAN
, "lij", "IT", k0
},
668 { LANGUAGE_USER_MINANGKABAU
, "min", "ID", k0
},
669 { LANGUAGE_USER_SUNDANESE
, "sun", "ID", k0
},
670 { LANGUAGE_USER_YAKA_DRCONGO
, "yaf", "CD", k0
},
671 { LANGUAGE_USER_ENGLISH_KENYA
, "en", "KE", k0
},
672 { LANGUAGE_USER_CABECAR
, "cjp", "CR", k0
},
673 { LANGUAGE_USER_BRIBRI
, "bzd", "CR", k0
},
674 { LANGUAGE_USER_ENGLISH_DENMARK
, "en", "DK", k0
},
675 { LANGUAGE_USER_SESOTHO_LESOTHO
, "st", "LS", k0
},
676 { LANGUAGE_USER_KLINGON
, "tlh", "" , k0
},
677 { LANGUAGE_USER_ENGLISH_ISRAEL
, "en", "IL", k0
},
678 { LANGUAGE_USER_PENNSYLVANIA_DUTCH
, "pdc", "US", k0
},
679 { LANGUAGE_USER_PORTUGUESE_MOZAMBIQUE
, "pt", "MZ", k0
},
680 { LANGUAGE_USER_SPANISH_EQUATORIAL_GUINEA
, "es", "GQ", k0
},
681 { LANGUAGE_USER_SPANISH_PHILIPPINES
, "es", "PH", k0
},
682 { LANGUAGE_USER_ENGLISH_ANTIGUA_BARBUDA
,"en", "AG", k0
},
683 { LANGUAGE_USER_SARAIKI
, "skr", "PK", k0
},
684 { LANGUAGE_USER_MORISYEN
, "mfe", "MU", k0
},
685 { LANGUAGE_USER_FRENCH_GUINEA
, "fr", "GN", k0
},
686 // Add new languages ^^^ there.
687 { LANGUAGE_MULTIPLE
, "mul", "" , k0
}, // multiple languages, many languages are used
688 { LANGUAGE_UNDETERMINED
, "und", "" , k0
}, // undetermined language, language cannot be identified
689 { LANGUAGE_NONE
, "zxx", "" , k0
}, // added to ISO 639-2 on 2006-01-11: Used to declare the absence of linguistic information
692 IsoLanguageScriptCountryEntry
const aImplIsoLangScriptEntries
[] =
694 // MS-LangID, ISO639-ISO15924, ISO3166, override
695 { LANGUAGE_SERBIAN_LATIN_SERBIA
, "sr-Latn", "RS", k0
},
696 { LANGUAGE_OBSOLETE_USER_SERBIAN_LATIN_SERBIA
, "sr-Latn", "RS", k0
},
697 { LANGUAGE_SERBIAN_LATIN_MONTENEGRO
, "sr-Latn", "ME", k0
},
698 { LANGUAGE_OBSOLETE_USER_SERBIAN_LATIN_MONTENEGRO
,"sr-Latn", "ME", k0
},
699 { LANGUAGE_SERBIAN_LATIN_BOSNIA_HERZEGOVINA
, "sr-Latn", "BA", k0
},
700 { LANGUAGE_SERBIAN_LATIN_SAM
, "sr-Latn", "CS", k0
}, // Serbian Latin in Serbia and Montenegro; note that not all applications may know about the 'CS' reusage mess, see https://en.wikipedia.org/wiki/ISO_3166-2:CS
701 { LANGUAGE_SERBIAN_LATIN_SAM
, "sr-Latn", "YU", k0
}, // legacy Serbian Latin in Yugoslavia
702 { LANGUAGE_SERBIAN_LATIN_LSO
, "sr-Latn", "" , k0
},
703 { LANGUAGE_SERBIAN_LATIN_NEUTRAL
, "sr-Latn", "" , LANGUAGE_SERBIAN_LATIN_LSO
}, // MS lists this as 'sr' only, what a mess
704 { LANGUAGE_SERBIAN_CYRILLIC_SERBIA
, "sr-Cyrl", "RS", kSAME
}, // MS
705 { LANGUAGE_SERBIAN_CYRILLIC_MONTENEGRO
, "sr-Cyrl", "ME", kSAME
}, // MS
706 { LANGUAGE_SERBIAN_CYRILLIC_BOSNIA_HERZEGOVINA
, "sr-Cyrl", "BA", kSAME
}, // MS
707 { LANGUAGE_SERBIAN_CYRILLIC_SAM
, "sr-Cyrl", "CS", kSAME
}, // MS
708 { LANGUAGE_SERBIAN_CYRILLIC_LSO
, "sr-Cyrl", "" , kSAME
}, // MS
709 { LANGUAGE_BOSNIAN_CYRILLIC_BOSNIA_HERZEGOVINA
, "bs-Cyrl", "BA", k0
},
710 { LANGUAGE_BOSNIAN_CYRILLIC_LSO
, "bs-Cyrl", "" , k0
},
711 { LANGUAGE_AZERI_CYRILLIC
, "az-Cyrl", "AZ", k0
}, // macrolanguage code; MS reserved since rev.15
712 { LANGUAGE_AZERI_CYRILLIC_LSO
, "az-Cyrl", "" , k0
}, // macrolanguage code
713 { LANGUAGE_UZBEK_CYRILLIC
, "uz-Cyrl", "UZ", k0
}, // macrolanguage code; MS reserved since rev.15
714 { LANGUAGE_UZBEK_CYRILLIC_LSO
, "uz-Cyrl", "" , k0
}, // macrolanguage code
715 { LANGUAGE_MONGOLIAN_CYRILLIC_MONGOLIA
, "mn-Cyrl", "MN", k0
}, // macrolanguage code; should be khk-MN or khk-Cyrl-MN
716 { LANGUAGE_MONGOLIAN_CYRILLIC_LSO
, "mn-Cyrl", "" , k0
}, // macrolanguage code; MS, should be khk or khk-Cyrl
717 { LANGUAGE_MONGOLIAN_MONGOLIAN_MONGOLIA
, "mn-Mong", "MN", k0
}, // macrolanguage code; MS, should be khk-Mong-MN
718 { LANGUAGE_MONGOLIAN_MONGOLIAN_CHINA
, "mn-Mong", "CN", k0
}, // macrolanguage code; MS reserved since rev.15; should actually be mvf-CN
719 { LANGUAGE_MONGOLIAN_MONGOLIAN_LSO
, "mn-Mong", "" , k0
}, // macrolanguage code
720 { LANGUAGE_USER_PALI_LATIN
, "pi-Latn", "" , k0
},
721 { LANGUAGE_USER_PALI_THAI
, "pi-Thai", "" , k0
},
722 { LANGUAGE_USER_KARAKALPAK_LATIN
, "kaa-Latn", "UZ", k0
},
723 { LANGUAGE_TAJIK
, "tg-Cyrl", "TJ", k0
}, // MS
724 { LANGUAGE_TAJIK_LSO
, "tg-Cyrl", "" , k0
}, // MS
725 { LANGUAGE_AZERI_LATIN
, "az-Latn", "AZ", k0
}, // macrolanguage code; MS
726 { LANGUAGE_AZERI_LATIN_LSO
, "az-Latn", "" , k0
}, // macrolanguage code; MS
727 { LANGUAGE_USER_YIDDISH_US
, "yi-Hebr", "US", kSAME
}, // macrolanguage code; MS, Hebr is suppress-script
728 { LANGUAGE_USER_YIDDISH_ISRAEL
, "yi-Hebr", "IL", kSAME
}, // macrolanguage code; MS, Hebr is suppress-script
729 { LANGUAGE_UZBEK_LATIN
, "uz-Latn", "UZ", k0
}, // macrolanguage code
730 { LANGUAGE_UZBEK_LATIN_LSO
, "uz-Latn", "" , k0
},
731 { LANGUAGE_SINDHI
, "sd-Deva", "IN", k0
}, // MS reserved
732 { LANGUAGE_SINDHI_PAKISTAN
, "sd-Arab", "PK", k0
}, // MS
733 { LANGUAGE_SINDHI_ARABIC_LSO
, "sd-Arab", "" , k0
},
734 { LANGUAGE_CHEROKEE_UNITED_STATES
, "chr-Cher", "US", k0
}, // MS
735 { LANGUAGE_CHEROKEE_CHEROKEE_LSO
, "chr-Cher", "" , k0
},
736 { LANGUAGE_INUKTITUT_SYLLABICS_CANADA
, "iu-Cans", "CA", k0
}, // macrolanguage code, MS
737 { LANGUAGE_INUKTITUT_SYLLABICS_LSO
, "iu-Cans", "" , k0
}, // macrolanguage code, MS
738 { LANGUAGE_INUKTITUT_LATIN_CANADA
, "iu-Latn", "CA", k0
}, // macrolanguage code, MS
739 { LANGUAGE_INUKTITUT_LATIN_LSO
, "iu-Latn", "" , k0
}, // macrolanguage code, MS
740 { LANGUAGE_TAMAZIGHT_TIFINAGH_MOROCCO
, "tzm-Tfng", "MA", k0
},
741 { LANGUAGE_TAMAZIGHT_TIFINAGH_LSO
, "tzm-Tfng", "" , k0
},
742 { LANGUAGE_KASHMIRI_INDIA
, "ks-Deva", "IN", k0
}, // MS since rev.15, earlier was "ks-Deva" reserved
743 { LANGUAGE_KASHMIRI
, "ks-Arab", "" , k0
}, // MS, Kashmiri in "Jammu and Kashmir" ... no ISO3166 code for that
744 { LANGUAGE_HAUSA_NIGERIA
, "ha-Latn", "NG", k0
}, // MS
745 { LANGUAGE_USER_HAUSA_GHANA
, "ha-Latn", "GH", k0
},
746 { LANGUAGE_HAUSA_LATIN_LSO
, "ha-Latn", "" , k0
},
747 { LANGUAGE_LATIN
, "la-Latn", "" , kSAME
}, // MS reserved until rev.15, though Latn is suppress-script, "la-VA" since rev.15
748 { LANGUAGE_TAI_NUA_CHINA
, "tdd-Tale", "CN", k0
}, // MS reserved
749 { LANGUAGE_LU_CHINA
, "khb-Talu", "CN", k0
}, // MS reserved
750 { LANGUAGE_KURDISH_ARABIC_IRAQ
, "ku-Arab", "IQ", kSAME
}, // macrolanguage code, MS
751 { LANGUAGE_KURDISH_ARABIC_LSO
, "ku-Arab", "" , kSAME
}, // macrolanguage code, MS
752 { LANGUAGE_USER_KURDISH_TURKEY
, "kmr-Latn", "TR", k0
},
753 { LANGUAGE_USER_KURDISH_SYRIA
, "kmr-Latn", "SY", k0
},
754 { LANGUAGE_PUNJABI_PAKISTAN
, "pnb-Arab", "PK", k0
},
755 { LANGUAGE_PUNJABI_ARABIC_LSO
, "pnb-Arab", "" , k0
},
756 { LANGUAGE_PUNJABI_PAKISTAN
, "pa-Arab", "PK", k0
}, // MS, incorrect
757 { LANGUAGE_PUNJABI_ARABIC_LSO
, "pa-Arab", "" , k0
}, // MS, incorrect
758 { LANGUAGE_TAMAZIGHT_LATIN_ALGERIA
, "tzm-Latn", "DZ", kSAME
}, // MS
759 { LANGUAGE_TAMAZIGHT_LATIN_LSO
, "tzm-Latn", "" , k0
}, // MS
760 { LANGUAGE_FULFULDE_NIGERIA
, "ff-Latn", "NG", kSAME
}, // macrolanguage code; MS since rev.15
761 { LANGUAGE_FULFULDE_SENEGAL
, "ff-Latn", "SN", k0
}, // macrolanguage code, MS
762 { LANGUAGE_FULFULDE_LATIN_LSO
, "ff-Latn", "" , k0
}, // macrolanguage code
763 { LANGUAGE_BOSNIAN_LATIN_BOSNIA_HERZEGOVINA
, "bs-Latn", "BA", kSAME
}, // MS, though Latn is suppress-script
764 { LANGUAGE_BOSNIAN_LATIN_LSO
, "bs-Latn", "" , LANGUAGE_BOSNIAN_LSO
}, // MS, though Latn is suppress-script
765 { LANGUAGE_CHINESE_TRADITIONAL_LSO
, "zh-Hant", "" , k0
},
766 { LANGUAGE_CHINESE_SIMPLIFIED
, "zh-Hans", "CN", kSAME
}, // canonical, but prefer legacy zh-CN
767 { LANGUAGE_CHINESE_TRADITIONAL
, "zh-Hant", "TW", kSAME
}, // canonical, but prefer legacy zh-TW
768 { LANGUAGE_CHINESE_SINGAPORE
, "zh-Hans", "SG", kSAME
}, // canonical, but prefer legacy zh-SG
769 { LANGUAGE_CHINESE_HONGKONG
, "zh-Hant", "HK", kSAME
}, // canonical, but prefer legacy zh-HK
770 { LANGUAGE_CHINESE_MACAU
, "zh-Hant", "MO", kSAME
}, // canonical, but prefer legacy zh-MO
771 { LANGUAGE_USER_MANINKAKAN_EASTERN_LATIN
, "emk-Latn", "GN", k0
},
772 { LANGUAGE_USER_CREE_PLAINS_LATIN
, "crk-Latn", "CA", k0
},
773 { LANGUAGE_USER_CREE_PLAINS_SYLLABICS
, "crk-Cans", "CA", k0
},
774 { LANGUAGE_USER_CREE_PLAINS_LATIN
, "crk-Latn", "CN", kSAME
}, // erroneous tdf#73973
775 { LANGUAGE_USER_CREE_PLAINS_SYLLABICS
, "crk-Cans", "CN", kSAME
}, // erroneous tdf#73973
776 { LANGUAGE_USER_HUNGARIAN_ROVAS
, "hu-Hung", "HU", k0
},
777 { LANGUAGE_USER_MALAY_ARABIC_MALAYSIA
, "ms-Arab", "MY", k0
},
778 { LANGUAGE_USER_MALAY_ARABIC_BRUNEI
, "ms-Arab", "BN", k0
},
779 { LANGUAGE_KAZAKH_LATIN
, "kk-Latn", "KZ", k0
},
780 { LANGUAGE_KAZAKH_LATIN_LSO
, "kk-Latn", "" , k0
}, // MS reserved
781 { LANGUAGE_KAZAKH_CYRILLIC_LSO
, "kk-Cyrl", "" , k0
}, // MS reserved
782 { LANGUAGE_KANURI_NIGERIA
, "kr-Latn", "NG", k0
}, // macrolanguage code; MS since rev.15
783 { LANGUAGE_TAMAZIGHT_ARABIC_MOROCCO
, "tzm-Arab", "MA", k0
}, // MS since rev.15, was reserved
784 { LANGUAGE_USER_ROHINGYA_HANIFI
, "rhg-Rhog", "MM", k0
},
785 { LANGUAGE_USER_SANTALI_OLCHIKI_INDIA
, "sat-Olck", "IN", k0
},
788 Bcp47CountryEntry
const aImplBcp47CountryEntries
[] =
790 // MS-LangID full BCP47, ISO3166, ISO639-Variant or other fallback
791 { LANGUAGE_CATALAN_VALENCIAN
, "ca-ES-valencia", "ES", "ca-valencia", k0
},
792 { LANGUAGE_OBSOLETE_USER_CATALAN_VALENCIAN
, "ca-ES-valencia", "ES", "", k0
}, // In case MS format files using the old value escaped into the wild, map them back.
793 { LANGUAGE_USER_ENGLISH_UK_OXENDICT
, "en-GB-oxendict", "GB", "", k0
},
794 { LANGUAGE_USER_ENGLISH_UK_OED
, "en-GB-oed", "GB", "", LANGUAGE_USER_ENGLISH_UK_OXENDICT
}, // grandfathered, deprecated, prefer en-GB-oxendict
795 { LANGUAGE_SPANISH_DATED
, "es-ES-u-co-trad", "ES", "es-u-co-trad", k0
}, // RFC6067/CLDR
796 { LANGUAGE_SPANISH_DATED
, "es-ES_tradnl", "ES", "", kSAME
}, // MS malformed
797 { LANGUAGE_OCCITAN_FRANCE
, "oc-FR-lengadoc", "FR", "oc-lengadoc", k0
},
798 { LANGUAGE_USER_OCCITAN_ARANESE
, "oc-ES-aranes", "ES", "oc-aranes", k0
},
799 // { LANGUAGE_YUE_CHINESE_HONGKONG, "zh-yue-HK", "HK", "", 0 }, // MS reserved, prefer yue-HK; do not add unless LanguageTag::simpleExtract() can handle it to not call liblangtag for rsc!
800 { LANGUAGE_YIDDISH
, "yi-001", "", "", k0
}, // MS since rev.15, was "yi-Hebr" reserved, "001"="World"
801 { LANGUAGE_FRENCH_WEST_INDIES
, "fr-029", "", "", k0
}, // MS since rev.15, was "Neither defined nor reserved", "029"="Caribbean"
802 { LANGUAGE_SPANISH_LATIN_AMERICA
, "es-419", "", "", k0
}, // MS reserved since rev.15, "419"="Latin America and the Caribbean"
803 { LANGUAGE_OBSOLETE_USER_SPANISH_LATIN_AMERICA
, "es-419", "", "", LANGUAGE_SPANISH_LATIN_AMERICA
},
804 { LANGUAGE_USER_INTERSLAVIC_LATIN
, "art-Latn-x-interslv", "", "", k0
}, // see discussion in tdf#145853
805 { LANGUAGE_USER_INTERSLAVIC_CYRILLIC
, "art-Cyrl-x-interslv", "", "", k0
},
808 const IsoLanguageCountryEntry aLastResortFallbackEntry
=
809 { LANGUAGE_ENGLISH_US
, "en", "US", k0
};
811 OUString
IsoLanguageCountryEntry::getTagString() const
814 return OUString( OUString::createFromAscii( maLanguage
) + "-" + OUString::createFromAscii( maCountry
));
816 return OUString::createFromAscii( maLanguage
);
819 css::lang::Locale
IsoLanguageCountryEntry::getLocale() const
821 return lang::Locale( OUString::createFromAscii( maLanguage
), OUString::createFromAscii( maCountry
), OUString());
824 OUString
IsoLanguageScriptCountryEntry::getTagString() const
827 return OUString( OUString::createFromAscii( maLanguageScript
) + "-" + OUString::createFromAscii( maCountry
));
829 return OUString::createFromAscii( maLanguageScript
);
832 css::lang::Locale
IsoLanguageScriptCountryEntry::getLocale() const
834 return lang::Locale( I18NLANGTAG_QLT
, OUString::createFromAscii( maCountry
), getTagString());
837 bool IsoLanguageScriptCountryEntry::startsInIgnoreAsciiCase( std::u16string_view aStr
) const
839 return o3tl::matchIgnoreAsciiCase(aStr
, std::string_view(maLanguageScript
) );
842 OUString
Bcp47CountryEntry::getTagString() const
844 return OUString::createFromAscii( mpBcp47
);
847 css::lang::Locale
Bcp47CountryEntry::getLocale() const
849 return lang::Locale( I18NLANGTAG_QLT
, OUString::createFromAscii( maCountry
), getTagString());
853 // In this table are the countries which should mapped to a specific
855 IsoLangEngEntry
const aImplIsoLangEngEntries
[] =
857 { LANGUAGE_ENGLISH_UK
, "AO" }, // Angola
858 { LANGUAGE_ENGLISH_UK
, "BJ" }, // Benin
859 { LANGUAGE_ENGLISH_UK
, "BW" }, // Botswana
860 { LANGUAGE_ENGLISH_UK
, "BI" }, // Burundi
861 { LANGUAGE_ENGLISH_UK
, "CM" }, // Cameroon
862 { LANGUAGE_ENGLISH_UK
, "GA" }, // Gabon
863 { LANGUAGE_ENGLISH_UK
, "GM" }, // Gambia
864 { LANGUAGE_ENGLISH_UK
, "GH" }, // Ghana
865 { LANGUAGE_ENGLISH_UK
, "GN" }, // Guinea
866 { LANGUAGE_ENGLISH_UK
, "LS" }, // Lesotho
867 { LANGUAGE_ENGLISH_UK
, "MW" }, // Malawi
868 { LANGUAGE_ENGLISH_UK
, "MT" }, // Malta
869 { LANGUAGE_ENGLISH_UK
, "NA" }, // Namibia
870 { LANGUAGE_ENGLISH_UK
, "NG" }, // Nigeria
871 { LANGUAGE_ENGLISH_UK
, "UG" }, // Uganda
872 { LANGUAGE_ENGLISH_UK
, "ZM" }, // Zambia
873 { LANGUAGE_ENGLISH_UK
, "ZW" }, // Zimbabwe
874 { LANGUAGE_ENGLISH_UK
, "SZ" }, // Swaziland
875 { LANGUAGE_ENGLISH_UK
, "NG" }, // Sierra Leone
876 { LANGUAGE_ENGLISH_UK
, "KN" }, // Saint Kitts and Nevis
877 { LANGUAGE_ENGLISH_UK
, "SH" }, // St. Helena
878 { LANGUAGE_ENGLISH_UK
, "IO" }, // British Indian Oceanic Territory
879 { LANGUAGE_ENGLISH_UK
, "FK" }, // Falkland Islands
880 { LANGUAGE_ENGLISH_UK
, "GI" }, // Gibraltar
881 { LANGUAGE_ENGLISH_UK
, "KI" }, // Kiribati
882 { LANGUAGE_ENGLISH_UK
, "VG" }, // Virgin Islands
883 { LANGUAGE_ENGLISH_UK
, "MU" }, // Mauritius
884 { LANGUAGE_ENGLISH_UK
, "FJ" }, // Fiji
885 { LANGUAGE_ENGLISH_US
, "KI" }, // Kiribati
886 { LANGUAGE_ENGLISH_US
, "LR" }, // Liberia
887 { LANGUAGE_ENGLISH_US
, "GU" }, // Guam
888 { LANGUAGE_ENGLISH_US
, "MH" }, // Marshall Islands
889 { LANGUAGE_ENGLISH_US
, "PW" }, // Palau
890 { LANGUAGE_ENGLISH_CARIBBEAN
, "AI" }, // Anguilla
891 { LANGUAGE_ENGLISH_CARIBBEAN
, "AG" }, // Antigua and Barbuda
892 { LANGUAGE_ENGLISH_CARIBBEAN
, "BS" }, // Bahamas
893 { LANGUAGE_ENGLISH_CARIBBEAN
, "BB" }, // Barbados
894 { LANGUAGE_ENGLISH_CARIBBEAN
, "BM" }, // Bermuda
895 { LANGUAGE_ENGLISH_CARIBBEAN
, "KY" }, // Cayman Islands
896 { LANGUAGE_ENGLISH_CARIBBEAN
, "GD" }, // Grenada
897 { LANGUAGE_ENGLISH_CARIBBEAN
, "DM" }, // Dominica
898 { LANGUAGE_ENGLISH_CARIBBEAN
, "HT" }, // Haiti
899 { LANGUAGE_ENGLISH_CARIBBEAN
, "MS" }, // Montserrat
900 { LANGUAGE_ENGLISH_CARIBBEAN
, "FM" }, // Micronesia
901 { LANGUAGE_ENGLISH_CARIBBEAN
, "VC" }, // St. Vincent / Grenadines
902 { LANGUAGE_ENGLISH_CARIBBEAN
, "LC" }, // Saint Lucia
903 { LANGUAGE_ENGLISH_CARIBBEAN
, "TC" }, // Turks & Caicos Islands
904 { LANGUAGE_ENGLISH_CARIBBEAN
, "GY" }, // Guyana
905 { LANGUAGE_ENGLISH_CARIBBEAN
, "TT" }, // Trinidad and Tobago
906 { LANGUAGE_ENGLISH_AUS
, "CX" }, // Christmas Islands
907 { LANGUAGE_ENGLISH_AUS
, "CC" }, // Cocos (Keeling) Islands
908 { LANGUAGE_ENGLISH_AUS
, "NF" }, // Norfolk Island
909 { LANGUAGE_ENGLISH_AUS
, "PG" }, // Papua New Guinea
910 { LANGUAGE_ENGLISH_AUS
, "SB" }, // Solomon Islands
911 { LANGUAGE_ENGLISH_AUS
, "TV" }, // Tuvalu
912 { LANGUAGE_ENGLISH_AUS
, "NR" }, // Nauru
913 { LANGUAGE_ENGLISH_NZ
, "CK" }, // Cook Islands
914 { LANGUAGE_ENGLISH_NZ
, "NU" }, // Niue
915 { LANGUAGE_ENGLISH_NZ
, "TK" }, // Tokelau
916 { LANGUAGE_ENGLISH_NZ
, "TO" }, // Tonga
917 { LANGUAGE_DONTKNOW
, "" } // marks end of table
921 IsoLangNoneStdEntry
const aImplIsoNoneStdLangEntries
[] =
923 { LANGUAGE_NORWEGIAN_BOKMAL
, "no", "BOK" }, // registered subtags for "no" in rfc1766
924 { LANGUAGE_NORWEGIAN_NYNORSK
, "no", "NYN" }, // registered subtags for "no" in rfc1766
925 { LANGUAGE_SERBIAN_LATIN_SAM
, "sr", "latin" },
926 { LANGUAGE_SERBIAN_CYRILLIC_SAM
, "sr", "cyrillic" },
927 { LANGUAGE_AZERI_LATIN
, "az", "latin" },
928 { LANGUAGE_AZERI_CYRILLIC
, "az", "cyrillic" },
929 { LANGUAGE_DONTKNOW
, "", "" } // marks end of table
933 // in this table are only names to find the best language
934 IsoLangNoneStdEntry
const aImplIsoNoneStdLangEntries2
[] =
936 { LANGUAGE_NORWEGIAN_BOKMAL
, "no", "bokmaal" },
937 { LANGUAGE_NORWEGIAN_BOKMAL
, "no", "bokmal" },
938 { LANGUAGE_NORWEGIAN_NYNORSK
, "no", "nynorsk" },
939 { LANGUAGE_DONTKNOW
, "", "" } // marks end of table
943 // in this table are only names to find the best language
944 IsoLangOtherEntry
const aImplOtherEntries
[] =
946 { LANGUAGE_ENGLISH_US
, "c" },
947 { LANGUAGE_CHINESE
, "chinese" },
948 { LANGUAGE_GERMAN
, "german" },
949 { LANGUAGE_JAPANESE
, "japanese" },
950 { LANGUAGE_KOREAN
, "korean" },
951 { LANGUAGE_ENGLISH_US
, "posix" },
952 { LANGUAGE_CHINESE_TRADITIONAL
, "tchinese" },
953 { LANGUAGE_DONTKNOW
, nullptr } // marks end of table
957 // in this table are only privateuse names
958 IsoLangOtherEntry
const aImplPrivateUseEntries
[] =
960 { LANGUAGE_USER_PRIV_NOTRANSLATE
, "x-no-translate" }, //! not BCP47 but legacy in .xcu configmgr
961 { LANGUAGE_USER_PRIV_DEFAULT
, "x-default" },
962 { LANGUAGE_USER_PRIV_COMMENT
, "x-comment" },
963 { LANGUAGE_USER_PRIV_NONE
, "x-none" },
964 { LANGUAGE_USER_PRIV_JOKER
, "*" }, //! not BCP47 but transferable in configmgr
965 { LANGUAGE_DONTKNOW
, nullptr } // marks end of table
970 void MsLangId::Conversion::convertLanguageToLocaleImpl( LanguageType nLang
,
971 css::lang::Locale
& rLocale
, bool bIgnoreOverride
)
973 if (nLang
== LANGUAGE_ENGLISH_US
)
975 // Speed-up a gazillion fallback cases, not iterating through
976 // aImplBcp47CountryEntries nor aImplIsoLangScriptEntries.
977 rLocale
.Language
= "en";
978 rLocale
.Country
= "US";
979 rLocale
.Variant
.clear();
983 const Bcp47CountryEntry
* pBcp47EntryOverride
= nullptr;
984 const IsoLanguageScriptCountryEntry
* pScriptEntryOverride
= nullptr;
985 const IsoLanguageCountryEntry
* pEntryOverride
= nullptr;
987 Label_Override_Lang_Locale
:
989 // Search for LangID in BCP47
990 for (const auto& rBcp47Entry
: aImplBcp47CountryEntries
)
992 if (rBcp47Entry
.mnLang
== nLang
)
994 if (bIgnoreOverride
|| !rBcp47Entry
.mnOverride
)
996 rLocale
.Language
= I18NLANGTAG_QLT
;
997 rLocale
.Country
= OUString::createFromAscii(rBcp47Entry
.maCountry
);
998 rLocale
.Variant
= rBcp47Entry
.getTagString();
1001 else if (rBcp47Entry
.mnOverride
&& pBcp47EntryOverride
!= &rBcp47Entry
)
1003 pBcp47EntryOverride
= &rBcp47Entry
;
1004 nLang
= getOverrideLang(rBcp47Entry
.mnLang
, rBcp47Entry
.mnOverride
);
1005 goto Label_Override_Lang_Locale
;
1010 // Search for LangID in ISO lll-Ssss-CC
1011 for (const auto& rScriptEntry
: aImplIsoLangScriptEntries
)
1013 if (rScriptEntry
.mnLang
== nLang
)
1015 if (bIgnoreOverride
|| !rScriptEntry
.mnOverride
)
1017 rLocale
.Language
= I18NLANGTAG_QLT
;
1018 rLocale
.Country
= OUString::createFromAscii(rScriptEntry
.maCountry
);
1019 rLocale
.Variant
= rScriptEntry
.getTagString();
1022 else if (rScriptEntry
.mnOverride
&& pScriptEntryOverride
!= &rScriptEntry
)
1024 pScriptEntryOverride
= &rScriptEntry
;
1025 nLang
= getOverrideLang(rScriptEntry
.mnLang
, rScriptEntry
.mnOverride
);
1026 goto Label_Override_Lang_Locale
;
1031 // Search for LangID in ISO lll-CC
1032 for (const auto& rEntry
: aImplIsoLangEntries
)
1034 if (rEntry
.mnLang
== nLang
)
1036 if (bIgnoreOverride
|| !rEntry
.mnOverride
)
1038 rLocale
.Language
= OUString::createFromAscii(rEntry
.maLanguage
);
1039 rLocale
.Country
= OUString::createFromAscii(rEntry
.maCountry
);
1040 rLocale
.Variant
.clear();
1043 else if (rEntry
.mnOverride
&& pEntryOverride
!= &rEntry
)
1045 pEntryOverride
= &rEntry
;
1046 nLang
= getOverrideLang(rEntry
.mnLang
, rEntry
.mnOverride
);
1047 goto Label_Override_Lang_Locale
;
1052 // Look for privateuse definitions.
1053 for (const IsoLangOtherEntry
* pPrivateEntry
= aImplPrivateUseEntries
;
1054 pPrivateEntry
->mnLang
!= LANGUAGE_DONTKNOW
; ++pPrivateEntry
)
1056 if (pPrivateEntry
->mnLang
== nLang
)
1058 rLocale
.Language
= I18NLANGTAG_QLT
;
1059 rLocale
.Country
.clear();
1060 rLocale
.Variant
= OUString::createFromAscii( pPrivateEntry
->mpLanguage
);
1065 // Not found. Passed rLocale argument remains unchanged.
1070 css::lang::Locale
MsLangId::Conversion::getLocale( const IsoLanguageCountryEntry
* pEntry
)
1072 if (pEntry
->mnOverride
)
1074 lang::Locale aLocale
;
1075 convertLanguageToLocaleImpl( getOverrideLang( pEntry
->mnLang
, pEntry
->mnOverride
), aLocale
, false);
1079 return pEntry
->getLocale();
1083 css::lang::Locale
MsLangId::Conversion::getLocale( const IsoLanguageScriptCountryEntry
* pEntry
)
1085 if (pEntry
->mnOverride
)
1087 lang::Locale aLocale
;
1088 convertLanguageToLocaleImpl( getOverrideLang( pEntry
->mnLang
, pEntry
->mnOverride
), aLocale
, false);
1092 return pEntry
->getLocale();
1096 css::lang::Locale
MsLangId::Conversion::getLocale( const Bcp47CountryEntry
* pEntry
)
1098 if (pEntry
->mnOverride
)
1100 lang::Locale aLocale
;
1101 convertLanguageToLocaleImpl( getOverrideLang( pEntry
->mnLang
, pEntry
->mnOverride
), aLocale
, false);
1105 return pEntry
->getLocale();
1109 css::lang::Locale
MsLangId::Conversion::lookupFallbackLocale(
1110 const css::lang::Locale
& rLocale
)
1112 // language is lower case in table
1113 OUString aLowerLang
= rLocale
.Language
.toAsciiLowerCase();
1114 // country is upper case in table
1115 OUString aUpperCountry
= rLocale
.Country
.toAsciiUpperCase();
1116 sal_Int32 nCountryLen
= aUpperCountry
.getLength();
1118 if (rLocale
.Language
== I18NLANGTAG_QLT
)
1120 // Search in BCP47, only full match and one fallback, for other
1121 // fallbacks only LanguageTag can decide.
1122 for (const auto& rBcp47Entry
: aImplBcp47CountryEntries
)
1124 if ( rLocale
.Variant
.equalsIgnoreAsciiCase(rBcp47Entry
.getTagString()) ||
1125 rLocale
.Variant
.equalsIgnoreAsciiCaseAscii(rBcp47Entry
.mpFallback
))
1126 return getLocale(&rBcp47Entry
); // may override
1129 // Search in ISO lll-Ssss-CC
1130 const IsoLanguageScriptCountryEntry
* pFirstScript
= nullptr;
1131 for (const auto& rScriptEntry
: aImplIsoLangScriptEntries
)
1133 if (rScriptEntry
.startsInIgnoreAsciiCase(rLocale
.Variant
))
1135 if (rLocale
.Variant
.equalsIgnoreAsciiCase(rScriptEntry
.getTagString()))
1136 return getLocale(&rScriptEntry
); // may override
1138 pFirstScript
= &rScriptEntry
;
1141 // If at least a lll-Ssss matched, try that with country or use it as
1145 // Check for country only if there is more than lll-Ssss-CC in tag
1146 // string, else we would had matched it already.
1147 if (!aUpperCountry
.isEmpty() && rLocale
.Variant
.getLength() > 11)
1149 for (const IsoLanguageScriptCountryEntry
* pScriptEntry
= pFirstScript
;
1150 pScriptEntry
!= std::end(aImplIsoLangScriptEntries
); ++pScriptEntry
)
1152 if (aUpperCountry
.equalsAscii( pScriptEntry
->maCountry
) &&
1153 pScriptEntry
->startsInIgnoreAsciiCase( rLocale
.Variant
))
1154 return getLocale( pScriptEntry
); // may override
1157 return getLocale( pFirstScript
); // may override
1160 // Extract language from tag string, country is used as present in
1161 // Locale because in the tables that follow we have only ISO 3166
1162 // countries and if that is in the tag string we also have it in the
1164 aLowerLang
= rLocale
.Variant
.getToken(0, '-').toAsciiLowerCase();
1165 // Nothing with "x-..." or "i-..." or any 1 letter in lll-CC table that
1167 if (aLowerLang
.getLength() == 1)
1168 return aLastResortFallbackEntry
.getLocale();
1171 // Search for locale and remember first lang-only.
1172 const IsoLanguageCountryEntry
* pFirstLang
= nullptr;
1173 for (const auto& rEntry
: aImplIsoLangEntries
)
1175 if (aLowerLang
.equalsAscii(rEntry
.maLanguage
))
1177 if (*rEntry
.maCountry
)
1179 if (nCountryLen
&& aUpperCountry
.equalsAscii(rEntry
.maCountry
))
1180 return getLocale(&rEntry
); // may override
1184 if (rEntry
.mnLang
.anyOf(
1185 // These are known to have no country assigned.
1186 LANGUAGE_USER_ESPERANTO
,
1187 LANGUAGE_USER_INTERLINGUA
,
1188 LANGUAGE_USER_INTERLINGUE
,
1189 LANGUAGE_USER_LOJBAN
,
1191 LANGUAGE_USER_KLINGON
,
1192 LANGUAGE_USER_KEYID
,
1193 // And the special codes without country.
1195 LANGUAGE_UNDETERMINED
,
1198 return getLocale(&rEntry
); // may override
1201 // Search for first entry of language with any country.
1202 if (!pFirstLang
&& *rEntry
.maCountry
)
1203 pFirstLang
= &rEntry
;
1208 return getLocale(pFirstLang
); // may override
1210 return aLastResortFallbackEntry
.getLocale();
1215 LanguageType
MsLangId::Conversion::convertPrivateUseToLanguage( std::u16string_view rPriv
)
1217 for (const IsoLangOtherEntry
* pPrivateEntry
= aImplPrivateUseEntries
;
1218 pPrivateEntry
->mnLang
!= LANGUAGE_DONTKNOW
; ++pPrivateEntry
)
1220 if ( o3tl::equalsIgnoreAsciiCase(rPriv
, pPrivateEntry
->mpLanguage
) )
1221 return pPrivateEntry
->mnLang
;
1223 return LANGUAGE_DONTKNOW
;
1228 LanguageType
MsLangId::Conversion::convertLocaleToLanguageImpl(
1229 const css::lang::Locale
& rLocale
)
1231 if (rLocale
.Language
== I18NLANGTAG_QLT
)
1233 // "x-..." private use and the nasty "*" joker
1234 if (rLocale
.Variant
.startsWithIgnoreAsciiCase( "x-") || (rLocale
.Variant
== "*"))
1235 return convertPrivateUseToLanguage( rLocale
.Variant
);
1238 for (const auto& rBcp47Entry
: aImplBcp47CountryEntries
)
1240 if (rLocale
.Variant
.equalsIgnoreAsciiCase(rBcp47Entry
.getTagString()))
1241 return getOverrideLang(rBcp47Entry
.mnLang
, rBcp47Entry
.mnOverride
);
1244 // Search in ISO lll-Ssss-CC
1245 for (const auto& rScriptEntry
: aImplIsoLangScriptEntries
)
1247 if (rScriptEntry
.startsInIgnoreAsciiCase(rLocale
.Variant
))
1249 if (rLocale
.Variant
.equalsIgnoreAsciiCase(rScriptEntry
.getTagString()))
1250 return getOverrideLang(rScriptEntry
.mnLang
, rScriptEntry
.mnOverride
);
1256 // language is lower case in table
1257 OUString aLowerLang
= rLocale
.Language
.toAsciiLowerCase();
1258 // country is upper case in table
1259 OUString aUpperCountry
= rLocale
.Country
.toAsciiUpperCase();
1261 // Search in ISO lll-CC
1262 for (const auto& rEntry
: aImplIsoLangEntries
)
1264 if (aLowerLang
.equalsAscii(rEntry
.maLanguage
) && aUpperCountry
.equalsAscii(rEntry
.maCountry
))
1265 return getOverrideLang(rEntry
.mnLang
, rEntry
.mnOverride
);
1268 return LANGUAGE_DONTKNOW
;
1273 css::lang::Locale
MsLangId::Conversion::getOverride( const css::lang::Locale
& rLocale
)
1275 if (rLocale
.Language
== I18NLANGTAG_QLT
)
1277 // "x-..." private use and the nasty "*" joker
1278 if (rLocale
.Variant
.startsWithIgnoreAsciiCase( "x-") || (rLocale
.Variant
== "*"))
1279 return rLocale
; // no overrides
1282 for (const auto& rBcp47Entry
: aImplBcp47CountryEntries
)
1284 if (rLocale
.Variant
.equalsIgnoreAsciiCase(rBcp47Entry
.getTagString()))
1285 return getLocale(&rBcp47Entry
); // may override
1288 // Search in ISO lll-Ssss-CC
1289 for (const auto& rScriptEntry
: aImplIsoLangScriptEntries
)
1291 if (rScriptEntry
.startsInIgnoreAsciiCase(rLocale
.Variant
))
1293 if (rLocale
.Variant
.equalsIgnoreAsciiCase(rScriptEntry
.getTagString()))
1294 return getLocale(&rScriptEntry
); // may override
1300 // language is lower case in table
1301 OUString aLowerLang
= rLocale
.Language
.toAsciiLowerCase();
1302 // country is upper case in table
1303 OUString aUpperCountry
= rLocale
.Country
.toAsciiUpperCase();
1305 // Search in ISO lll-CC
1306 for (const auto& rEntry
: aImplIsoLangEntries
)
1308 if (aLowerLang
.equalsAscii(rEntry
.maLanguage
) && aUpperCountry
.equalsAscii(rEntry
.maCountry
))
1309 return getLocale(&rEntry
); // may override
1312 return lang::Locale();
1317 LanguageType
MsLangId::Conversion::convertIsoNamesToLanguage( const OUString
& rLang
,
1318 const OUString
& rCountry
, bool bSkipIsoTable
)
1320 // language is lower case in table
1321 OUString aLowerLang
= rLang
.toAsciiLowerCase();
1322 // country is upper case in table
1323 OUString aUpperCountry
= rCountry
.toAsciiUpperCase();
1327 // first look for exact match
1328 for (const auto& rEntry
: aImplIsoLangEntries
)
1330 if ( aLowerLang
.equalsAscii(rEntry
.maLanguage
) )
1332 if ( aUpperCountry
.isEmpty() ||
1333 aUpperCountry
.equalsAscii(rEntry
.maCountry
) )
1334 return rEntry
.mnLang
;
1338 // some eng countries should be mapped to a specific english language
1339 if ( aLowerLang
== "en" )
1341 for (const IsoLangEngEntry
* pEngEntry
= aImplIsoLangEngEntries
;
1342 pEngEntry
->mnLang
!= LANGUAGE_DONTKNOW
; ++pEngEntry
)
1344 if ( aUpperCountry
.equalsAscii( pEngEntry
->maCountry
) )
1345 return pEngEntry
->mnLang
;
1350 // test for specific languages which are not used standard ISO 3166 codes
1351 for (const IsoLangNoneStdEntry
* pNoneStdEntry
= aImplIsoNoneStdLangEntries
;
1352 pNoneStdEntry
->mnLang
!= LANGUAGE_DONTKNOW
; ++pNoneStdEntry
)
1354 if ( aLowerLang
.equalsAscii( pNoneStdEntry
->maLanguage
) )
1356 // The countries in this table are not all in upper case
1357 if ( aUpperCountry
.equalsIgnoreAsciiCaseAscii( pNoneStdEntry
->maCountry
) )
1358 return pNoneStdEntry
->mnLang
;
1361 for (const IsoLangNoneStdEntry
* pNoneStdEntry2
= aImplIsoNoneStdLangEntries2
;
1362 pNoneStdEntry2
->mnLang
!= LANGUAGE_DONTKNOW
; ++pNoneStdEntry2
)
1364 if ( aLowerLang
.equalsAscii( pNoneStdEntry2
->maLanguage
) )
1366 // The countries in this table are not all in upper case
1367 if ( aUpperCountry
.equalsIgnoreAsciiCaseAscii( pNoneStdEntry2
->maCountry
) )
1368 return pNoneStdEntry2
->mnLang
;
1374 // if only the country is set, look for any entry matching the country
1375 // (to allow reading country and language in separate steps, in any order)
1376 if ( !rCountry
.isEmpty() && rLang
.isEmpty() )
1378 for (const auto& rEntry2
: aImplIsoLangEntries
)
1380 if ( aUpperCountry
.equalsAscii(rEntry2
.maCountry
) )
1381 return rEntry2
.mnLang
;
1384 aLowerLang
= aUpperCountry
.toAsciiLowerCase();
1388 // Look for privateuse definitions.
1389 LanguageType nLang
= convertPrivateUseToLanguage( aLowerLang
);
1390 if (nLang
!= LANGUAGE_DONTKNOW
)
1393 // Now look for all other definitions, which are not standard
1394 for (const IsoLangOtherEntry
* pOtherEntry
= aImplOtherEntries
;
1395 pOtherEntry
->mnLang
!= LANGUAGE_DONTKNOW
; ++pOtherEntry
)
1397 if ( aLowerLang
.equalsAscii( pOtherEntry
->mpLanguage
) )
1398 return pOtherEntry
->mnLang
;
1401 return LANGUAGE_DONTKNOW
;
1406 LanguageType
MsLangId::Conversion::convertIsoNamesToLanguage( std::string_view rLang
,
1407 std::string_view rCountry
)
1409 OUString aLang
= OStringToOUString( rLang
, RTL_TEXTENCODING_ASCII_US
);
1410 OUString aCountry
= OStringToOUString( rCountry
, RTL_TEXTENCODING_ASCII_US
);
1411 LanguageType nLang
= convertIsoNamesToLanguage( aLang
, aCountry
, false);
1413 // XXX: called *only* by static convertUnxByteStringToLanguage() so we can
1414 // actually call into LanguageTag to create an on-the-fly mapping.
1415 if (nLang
== LANGUAGE_DONTKNOW
)
1417 OUString
aTag( aCountry
.isEmpty() ? aLang
: aLang
+ "-" + aCountry
);
1418 nLang
= LanguageTag( aTag
).getLanguageType(false);
1419 SAL_WARN("i18nlangtag", "convertIsoNamesToLanguage(string_view): on-the-fly for {"
1420 << aTag
<< "} " << nLang
);
1421 // Do not leave empty as SYSTEM unresolved.
1422 if (nLang
== LANGUAGE_DONTKNOW
|| nLang
== LANGUAGE_SYSTEM
)
1424 SAL_WARN("i18nlangtag", "convertIsoNamesToLanguage(string_view): on-the-fly bad, using {en-US}");
1425 nLang
= LANGUAGE_ENGLISH_US
;
1433 struct IsoLangGLIBCModifiersEntry
1435 LanguageType mnLang
;
1443 IsoLangGLIBCModifiersEntry
const aImplIsoLangGLIBCModifiersEntries
[] =
1445 // MS-LANGID codes ISO639-1/2/3 ISO3166 glibc modifier
1446 { LANGUAGE_BOSNIAN_CYRILLIC_BOSNIA_HERZEGOVINA
, "bs", "BA", "cyrillic" },
1447 { LANGUAGE_USER_SERBIAN_LATIN_SERBIA
, "sr", "RS", "latin" }, // Serbian Latin in Serbia
1448 { LANGUAGE_SERBIAN_LATIN_SAM
, "sr", "CS", "latin" }, // Serbian Latin in Serbia and Montenegro
1449 { LANGUAGE_USER_SERBIAN_LATIN_MONTENEGRO
, "sr", "ME", "latin" }, // Serbian Latin in Montenegro
1450 { LANGUAGE_SERBIAN_LATIN_LSO
, "sr", "", "latin" },
1451 { LANGUAGE_AZERI_CYRILLIC
, "az", "AZ", "cyrillic" },
1452 { LANGUAGE_UZBEK_CYRILLIC
, "uz", "UZ", "cyrillic" },
1453 { LANGUAGE_CATALAN_VALENCIAN
, "ca", "ES", "valencia" },
1454 { LANGUAGE_DONTKNOW
, "", "", "" } // marks end of table
1457 // convert a unix locale string into LanguageType
1460 LanguageType
MsLangId::convertUnxByteStringToLanguage(
1461 std::string_view rString
)
1467 size_t nLangSepPos
= rString
.find( '_' );
1468 size_t nCountrySepPos
= rString
.find( '.' );
1469 size_t nAtPos
= rString
.find( '@' );
1471 if (nCountrySepPos
== std::string_view::npos
)
1472 nCountrySepPos
= nAtPos
;
1473 if (nCountrySepPos
== std::string_view::npos
)
1474 nCountrySepPos
= rString
.size();
1476 if (nAtPos
!= std::string_view::npos
)
1477 aAtString
= OString(rString
.substr( nAtPos
+1 ));
1479 if (((nLangSepPos
!= std::string_view::npos
) && (nLangSepPos
> nCountrySepPos
)) || (nLangSepPos
== std::string_view::npos
))
1481 // eg. "el.sun_eu_greek", "tchinese", "es.ISO8859-15"
1482 aLang
= OString(rString
.substr( 0, nCountrySepPos
));
1484 else if ( nLangSepPos
!= std::string_view::npos
)
1486 // well formed iso names like "en_US.UTF-8", "sh_BA.ISO8859-2@bosnia"
1487 aLang
= OString(rString
.substr( 0, nLangSepPos
));
1488 aCountry
= OString(rString
.substr( nLangSepPos
+1, nCountrySepPos
- nLangSepPos
- 1));
1491 // if there is a glibc modifier, first look for exact match in modifier table
1492 if (!aAtString
.isEmpty())
1494 // language is lower case in table
1495 OString aLowerLang
= aLang
.toAsciiLowerCase();
1496 // country is upper case in table
1497 OString aUpperCountry
= aCountry
.toAsciiUpperCase();
1498 for (const IsoLangGLIBCModifiersEntry
* pGLIBCModifiersEntry
= aImplIsoLangGLIBCModifiersEntries
;
1499 pGLIBCModifiersEntry
->mnLang
!= LANGUAGE_DONTKNOW
; ++pGLIBCModifiersEntry
)
1500 { // avoid embedded \0 warning
1501 if (aLowerLang
== pGLIBCModifiersEntry
->maLanguage
&&
1502 aAtString
== pGLIBCModifiersEntry
->maAtString
)
1504 if (aUpperCountry
.isEmpty() ||
1505 aUpperCountry
== pGLIBCModifiersEntry
->maCountry
)
1507 return pGLIBCModifiersEntry
->mnLang
;
1513 return Conversion::convertIsoNamesToLanguage( aLang
, aCountry
);
1518 ::std::vector
< MsLangId::LanguagetagMapping
> MsLangId::getDefinedLanguagetags()
1520 ::std::vector
< LanguagetagMapping
> aVec
;
1521 aVec
.reserve(std::size(aImplBcp47CountryEntries
) + std::size(aImplIsoLangScriptEntries
)
1522 + std::size(aImplIsoLangEntries
));
1524 for (const auto& rEntry
: aImplBcp47CountryEntries
)
1525 aVec
.emplace_back(rEntry
.getTagString(), rEntry
.mnLang
);
1527 for (const auto& rEntry
: aImplIsoLangScriptEntries
)
1528 aVec
.emplace_back(rEntry
.getTagString(), rEntry
.mnLang
);
1530 for (const auto& rEntry
: aImplIsoLangEntries
)
1531 aVec
.emplace_back(rEntry
.getTagString(), rEntry
.mnLang
);
1536 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */