summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorEike Rathke <erack@openoffice.org>2010-05-04 00:58:12 +0200
committerEike Rathke <erack@openoffice.org>2010-05-04 00:58:12 +0200
commit3eb3bb8924acdf2ede721bb3cecba961b849b638 (patch)
tree33e690a21a38dcb798d88335d9c489e1c02cf461 /i18npool
parentc59c00efa8bf1b934efeaa24ed98510fc7a23d7c (diff)
locales33a: #i111003# add support for known glibc modifiers; patch from <cmc>
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/source/isolang/isolang.cxx53
1 files changed, 52 insertions, 1 deletions
diff --git a/i18npool/source/isolang/isolang.cxx b/i18npool/source/isolang/isolang.cxx
index 026c505ef0e8..ff59fb02dcc4 100644
--- a/i18npool/source/isolang/isolang.cxx
+++ b/i18npool/source/isolang/isolang.cxx
@@ -1007,6 +1007,28 @@ LanguageType MsLangId::convertIsoByteStringToLanguage(
}
// -----------------------------------------------------------------------
+
+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
@@ -1015,15 +1037,20 @@ LanguageType MsLangId::convertUnxByteStringToLanguage(
{
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)) )
{
@@ -1037,6 +1064,30 @@ LanguageType MsLangId::convertUnxByteStringToLanguage(
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 );
}