diff options
author | Eike Rathke <erack@redhat.com> | 2013-03-27 20:20:50 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-03-27 20:38:18 +0100 |
commit | 46f47a6ec28dda0436b9c4fb54628a6e2e191285 (patch) | |
tree | e8348f681fb7f96e523597e0ef51ecb865c56d72 /i18npool | |
parent | a0edc3fc9cc77172aec6d865e4aaf2500229fd96 (diff) |
handle x-... privateuse conversion
Change-Id: I293ba38f02a93d161fd05beba02f2dcd974c63d3
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/inc/i18npool/mslangid.hxx | 4 | ||||
-rw-r--r-- | i18npool/source/isolang/isolang.cxx | 25 | ||||
-rw-r--r-- | i18npool/source/isolang/mslangid.cxx | 14 |
3 files changed, 33 insertions, 10 deletions
diff --git a/i18npool/inc/i18npool/mslangid.hxx b/i18npool/inc/i18npool/mslangid.hxx index c1682c3dd2c8..1f959adad6fd 100644 --- a/i18npool/inc/i18npool/mslangid.hxx +++ b/i18npool/inc/i18npool/mslangid.hxx @@ -215,6 +215,10 @@ public: I18NISOLANG_DLLPRIVATE static LanguageType convertLocaleToLanguage( const ::com::sun::star::lang::Locale & rLocale ); + /** Convert x-... privateuse, used by convertLocaleToLanguage(Locale) */ + I18NISOLANG_DLLPRIVATE static LanguageType convertPrivateUseToLanguage( + const rtl::OUString& rPriv ); + /** Used by convertLocaleToLanguage(Locale) */ I18NISOLANG_DLLPRIVATE static LanguageType convertIsoNamesToLanguage( const rtl::OUString& rLang, const rtl::OUString& rCountry ); diff --git a/i18npool/source/isolang/isolang.cxx b/i18npool/source/isolang/isolang.cxx index ba3b4e59fb6c..21b7370b9d19 100644 --- a/i18npool/source/isolang/isolang.cxx +++ b/i18npool/source/isolang/isolang.cxx @@ -848,6 +848,20 @@ static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry( // ======================================================================= // static +LanguageType MsLangId::Conversion::convertPrivateUseToLanguage( const rtl::OUString& rPriv ) +{ + const IsoLangOtherEntry* pPrivateEntry = aImplPrivateUseEntries; + do + { + if ( rPriv.equalsIgnoreAsciiCaseAscii( pPrivateEntry->mpLangStr ) ) + return pPrivateEntry->mnLang; + ++pPrivateEntry; + } while ( pPrivateEntry->mnLang != LANGUAGE_DONTKNOW ); + return LANGUAGE_DONTKNOW; +} + + +// static LanguageType MsLangId::Conversion::convertIsoNamesToLanguage( const rtl::OUString& rLang, const rtl::OUString& rCountry ) { @@ -935,14 +949,9 @@ LanguageType MsLangId::Conversion::convertIsoNamesToLanguage( const rtl::OUStrin } // Look for privateuse definitions. - const IsoLangOtherEntry* pPrivateEntry = aImplPrivateUseEntries; - do - { - if ( aLowerLang.equalsAscii( pPrivateEntry->mpLangStr ) ) - return pPrivateEntry->mnLang; - ++pPrivateEntry; - } - while ( pPrivateEntry->mnLang != LANGUAGE_DONTKNOW ); + LanguageType nLang = convertPrivateUseToLanguage( aLowerLang); + if (nLang != LANGUAGE_DONTKNOW) + return nLang; // Now look for all other definitions, which are not standard const IsoLangOtherEntry* pOtherEntry = aImplOtherEntries; diff --git a/i18npool/source/isolang/mslangid.cxx b/i18npool/source/isolang/mslangid.cxx index b3319aad632c..e417f33fe67f 100644 --- a/i18npool/source/isolang/mslangid.cxx +++ b/i18npool/source/isolang/mslangid.cxx @@ -148,6 +148,13 @@ void MsLangId::Conversion::convertLanguageToLocale( LanguageType nLang, if (!rLocale.Variant.isEmpty()) rLocale.Variant = rtl::OUString(); convertLanguageToIsoNames( nLang, rLocale.Language, rLocale.Country); + /* FIXME: this x-... is temporary until conversion will be moved up to + * LanguageTag */ + if (rLocale.Language.startsWith( "x-")) + { + rLocale.Variant = rLocale.Language; + rLocale.Language = "qlt"; + } } @@ -178,8 +185,11 @@ LanguageType MsLangId::Conversion::convertLocaleToLanguage( if (rLocale.Language.isEmpty()) return LANGUAGE_SYSTEM; - LanguageType nRet = convertIsoNamesToLanguage( rLocale.Language, - rLocale.Country); + /* FIXME: this x-... is temporary until conversion will be moved up to + * LanguageTag */ + LanguageType nRet = ((!rLocale.Variant.isEmpty() && rLocale.Variant.startsWithIgnoreAsciiCase( "x-")) ? + convertPrivateUseToLanguage( rLocale.Variant) : + convertIsoNamesToLanguage( rLocale.Language, rLocale.Country)); if (nRet == LANGUAGE_DONTKNOW) nRet = LANGUAGE_SYSTEM; |