diff -r e6f5a782baa3 i18npool/source/isolang/isolang.cxx --- a/i18npool/source/isolang/isolang.cxx Tue Apr 06 08:43:12 2010 +0100 +++ b/i18npool/source/isolang/isolang.cxx Tue Apr 20 09:35:10 2010 +0100 @@ -993,6 +993,28 @@ } // ----------------------------------------------------------------------- + +struct IsoLangGLIBCModifiersEntry +{ + LanguageType mnLang; + sal_Char maLangStr[4]; + sal_Char maCountry[3]; + sal_Char maAtString[9]; +}; + +static IsoLangGLIBCModifiersEntry const aImplIsoLangGLIBCModifiersEntries[] = +{ + // MS-LANGID codes ISO639-1/2/3 ISO3166 glibc modifier + { LANGUAGE_BOSNIAN_CYRILLIC_BOSNIA_HERZEGOVINA, "bs", "BA", "cyrillic" }, + { LANGUAGE_USER_SERBIAN_LATIN_SERBIA, "sr", "RS", "latin" }, // Serbian Latin in Serbia + { LANGUAGE_SERBIAN_LATIN, "sr", "CS", "latin" }, // Serbian Latin in Serbia and Montenegro + { LANGUAGE_USER_SERBIAN_LATIN_MONTENEGRO, "sr", "ME", "latin" }, // Serbian Latin in Montenegro + { LANGUAGE_SERBIAN_LATIN_NEUTRAL, "sr", "", "latin" }, + { LANGUAGE_AZERI_CYRILLIC, "az", "AZ", "cyrillic" }, + { LANGUAGE_UZBEK_CYRILLIC, "uz", "UZ", "cyrillic" }, + { LANGUAGE_DONTKNOW, "", "", "" } // marks end of table +}; + // convert a unix locale string into LanguageType // static @@ -1001,15 +1023,20 @@ { rtl::OString aLang; rtl::OString aCountry; + rtl::OString aAtString; sal_Int32 nLangSepPos = rString.indexOf( (sal_Char)'_' ); sal_Int32 nCountrySepPos = rString.indexOf( (sal_Char)'.' ); + sal_Int32 nAtPos = rString.indexOf( (sal_Char)'@' ); if (nCountrySepPos < 0) - nCountrySepPos = rString.indexOf( (sal_Char)'@' ); + nCountrySepPos = nAtPos; if (nCountrySepPos < 0) nCountrySepPos = rString.getLength(); + if (nAtPos >= 0) + aAtString = rString.copy( nAtPos+1 ); + if ( ((nLangSepPos >= 0) && (nLangSepPos > nCountrySepPos)) || ((nLangSepPos < 0)) ) { @@ -1023,6 +1050,30 @@ aCountry = rString.copy( nLangSepPos+1, nCountrySepPos - nLangSepPos - 1); } + // if there is a glibc modifier, first look for exact match in modifier table + if (aAtString.getLength()) + { + // language is lower case in table + rtl::OString aLowerLang = aLang.toAsciiLowerCase(); + // country is upper case in table + rtl::OString aUpperCountry = aCountry.toAsciiUpperCase(); + const IsoLangGLIBCModifiersEntry* pGLIBCModifiersEntry = aImplIsoLangGLIBCModifiersEntries; + do + { + if (( aLowerLang.equals( pGLIBCModifiersEntry->maLangStr ) ) && + ( aAtString.equals( pGLIBCModifiersEntry->maAtString ) )) + { + if ( !aUpperCountry.getLength() || + aUpperCountry.equals( pGLIBCModifiersEntry->maCountry ) ) + { + return pGLIBCModifiersEntry->mnLang; + } + } + ++pGLIBCModifiersEntry; + } + while ( pGLIBCModifiersEntry->mnLang != LANGUAGE_DONTKNOW ); + } + return convertIsoNamesToLanguage( aLang, aCountry ); }